'Verifies the traffic after updating the vm port
With new security group having appropriate rule.'

@decorators.idempotent_id('f4d556d7-1526-42ad-bafb-6bebf48568f6')
@decorators.attr(type='slow')
@test.services('compute', 'network')
def test_port_update_new_security_group(self):

    new_tenant = self.primary_tenant
    new_sg = self._create_empty_security_group(namestart='secgroup_new-', tenant_id=new_tenant.creds.tenant_id, client=new_tenant.manager.security_groups_client)
    icmp_rule = dict(protocol='icmp', direction='ingress')
    sec_group_rules_client = new_tenant.manager.security_group_rules_client
    self._create_security_group_rule(secgroup=new_sg, sec_group_rules_client=sec_group_rules_client, **icmp_rule)
    new_tenant.security_groups.update(new_sg=new_sg)
    name = 'server-{tenant}-gen-1'.format(tenant=new_tenant.creds.tenant_name)
    name = data_utils.rand_name(name)
    server = self._create_server(name, new_tenant, [new_tenant.security_groups['default']])
    try:
        access_point_ssh = self._connect_to_access_point(new_tenant)
        self.check_remote_connectivity(source=access_point_ssh, dest=self._get_server_ip(server), should_succeed=False)
        server_id = server['id']
        port_id = self.os_admin.ports_client.list_ports(device_id=server_id)['ports'][0]['id']
        self.ports_client.update_port(port_id, security_groups=[new_tenant.security_groups['new_sg']['id']])
        self.check_remote_connectivity(source=access_point_ssh, dest=self._get_server_ip(server))
    except Exception:
        self._log_console_output_for_all_tenants()
        raise
