Create a new vlan
771552
def create(gandi, name, datacenter, subnet, gateway, background):
    
    try:
        gandi.datacenter.is_opened(datacenter, 'iaas')
    except DatacenterLimited as exc:
        gandi.echo('/!\ Datacenter %s will be closed on %s, '
                   'please consider using another datacenter.' %
                   (datacenter, exc.date))

    result = gandi.vlan.create(name, datacenter, subnet, gateway, background)

    if background:
        gandi.pretty_echo(result)

    return result
733808
def vhost(name = nil, &block)
      attrs = VhostDirective.new(name, &block)
      Vhost.create(name: attrs[:name],
                   ip_address: attrs[:ip],
                   mac_address: attrs[:mac],
                   promisc: attrs[:promisc])
    end
1340842
public static ns_detail_vlan add(nitro_service client, ns_detail_vlan resource) throws Exception
	{
		resource.validate("add");
		return ((ns_detail_vlan[]) resource.perform_operation(client, "add"))[0];
	}
142705
def add_vlan_to_interface(self, interface, vlan_id):
        
        subif = '%s.%s' % (interface, vlan_id)
        vlan_id = '%s' % vlan_id
        cmd = ['ip', 'link', 'add', 'link', interface, 'name',
               subif, 'type', 'vlan', 'id', vlan_id]
        stdcode, stdout = agent_utils.execute(cmd, root=True)
        if stdcode == 0:
            return agent_utils.make_response(code=stdcode)
        # execute failed.
        message = stdout.pop(0)
        return agent_utils.make_response(code=stdcode, message=message)
386971
def create_vlan(self, nexus_host, vlanid, vni):
        """"""

        starttime = time.time()
        path_snip, body_snip = self.start_create_vlan()
        body_snip = self.get_create_vlan(nexus_host, vlanid, vni, body_snip)
        body_snip = self.end_create_vlan(body_snip)

        self.send_edit_string(nexus_host, path_snip, body_snip)

        self.capture_and_print_timeshot(
            starttime, "create_vlan_seg",
            switch=nexus_host)
885634
def create_network(userid, os_version, network_info):
    
    print("\nConfiguring network interface for %s ..." % userid)
    network_create_info = client.send_request('guest_create_network_interface', 
                                              userid, os_version, network_info)

    if network_create_info['overallRC']:
        raise RuntimeError("Failed to create network for guest %s!\n%s" % 
                           (userid, network_create_info))
    else:
        print("Succeeded to create network for guest %s!" % userid)
1026362
def create(cls, interface_id, logical_interface_ref, **kw):
        
        data = {'inspect_unspecified_vlans': True,
                'logical_interface_ref': logical_interface_ref,
                'nicid': str(interface_id)}
        
        if 'reset_interface_nicid' in kw:
            data.update(reset_interface_nicid=kw.get('reset_interface_nicid'))

        return cls(data)
1272398
def create_router(self, name, ext_network=None, admin_state_up=True):
        '''
        
        '''
        body = {'name': name,
                'admin_state_up': admin_state_up}
        if ext_network:
            net_id = self._find_network_id(ext_network)
            body['external_gateway_info'] = {'network_id': net_id}
        return self.network_conn.create_router(body={'router': body})
199566
def add_vnic_template(self, vlan_id, ucsm_ip, vnic_template, physnet):
        """"""
        if not self.get_vnic_template_vlan_entry(vlan_id, vnic_template,
            ucsm_ip, physnet):
            vnic_t = ucsm_model.VnicTemplate(vlan_id=vlan_id,
                                             vnic_template=vnic_template,
                                             device_id=ucsm_ip,
                                             physnet=physnet,
                                             updated_on_ucs=False)
            with self.session.begin(subtransactions=True):
                self.session.add(vnic_t)
            return vnic_t
460361
def create_and_trunk_vlan(self, nexus_host, vlan_id, intf_type,
                              nexus_port, vni, is_native):
        """"""

        starttime = time.time()

        self.create_vlan(nexus_host, vlan_id, vni)
        LOG.debug("NexusDriver created VLAN: %s", vlan_id)

        if nexus_port:
            self.send_enable_vlan_on_trunk_int(
                nexus_host, vlan_id,
                intf_type, nexus_port,
                is_native)

        self.capture_and_print_timeshot(
            starttime, "create_all",
            switch=nexus_host)
131965
async def save(self):
        """"""
        if 'vlan' in self._changed_data and self._changed_data['vlan']:
            # Update uses the ID of the VLAN, not the VLAN object.
            self._changed_data['vlan'] = self._changed_data['vlan']['id']
            if (self._orig_data['vlan'] and
                    'id' in self._orig_data['vlan'] and
                    self._changed_data['vlan'] == (
                        self._orig_data['vlan']['id'])):
                # VLAN didn't really change, the object was just set to the
                # same VLAN.
                del self._changed_data['vlan']
        await super(Subnet, self).save()
226471
def create(cls, interface_id, address, network_value,
               nodeid=1, **kwargs):
        
        data = {'address': address,
                'network_value': network_value,
                'nicid': str(interface_id),
                'auth_request': False,
                'backup_heartbeat': False,
                'nodeid': nodeid,
                'outgoing': False,
                'primary_mgt': False,
                'primary_heartbeat': False}

        for k, v in kwargs.items():
            data.update({k: v})

        return cls(data)
423238
def create_vs(self, name, ip, port, protocol, profile, pool_name):
        '''
        
        '''
        vs = self.bigIP.LocalLB.VirtualServer
        vs_def = vs.typefactory.create('Common.VirtualServerDefinition')

        vs_def.name = name
        vs_def.address = ip
        vs_def.port = port

        common_protocols = vs.typefactory.create('Common.ProtocolType')

        p = [i[0] for i in common_protocols if i[0].split('_')[1] == protocol.upper()]

        if p:
            vs_def.protocol = p
        else:
            raise CommandExecutionError('Unknown protocol')

        vs_def_seq = vs.typefactory.create('Common.VirtualServerSequence')
        vs_def_seq.item = [vs_def]

        vs_type = vs.typefactory.create(
            'LocalLB.VirtualServer.VirtualServerType'
        )
        vs_resource = vs.typefactory.create(
            'LocalLB.VirtualServer.VirtualServerResource'
        )

        vs_resource.type = vs_type.RESOURCE_TYPE_POOL
        vs_resource.default_pool_name = pool_name

        resource_seq = vs.typefactory.create(
            'LocalLB.VirtualServer.VirtualServerResourceSequence'
        )

        resource_seq.item = [vs_resource]

        vs_context = vs.typefactory.create('LocalLB.ProfileContextType')
        vs_profile = vs.typefactory.create(
            'LocalLB.VirtualServer.VirtualServerProfile'
        )

        vs_profile.profile_context = vs_context.PROFILE_CONTEXT_TYPE_ALL
        vs_profile.profile_name = protocol

        vs_profile_http = vs.typefactory.create(
            'LocalLB.VirtualServer.VirtualServerProfile'
        )
        vs_profile_http.profile_name = profile

        vs_profile_conn = vs.typefactory.create(
            'LocalLB.VirtualServer.VirtualServerProfile'
        )
        vs_profile_conn.profile_name = 'oneconnect'

        vs_profile_seq = vs.typefactory.create(
            'LocalLB.VirtualServer.VirtualServerProfileSequence'
        )
        vs_profile_seq.item = [vs_profile, vs_profile_http, vs_profile_conn]

        try:
            vs.create(definitions=vs_def_seq,
                      wildmasks=['255.255.255.255'],
                      resources=resource_seq,
                      profiles=[vs_profile_seq])
        except Exception as e:
            raise Exception(
                'Unable to create `{0}` virtual server\n\n{1}'.format(name, e)
            )
        return True
772781
def create(gandi, datacenter, bandwidth, ip_version, vlan, ip, attach,
           background):
    
    if ip_version != 4 and vlan:
        gandi.echo('You must have an --ip-version to 4 when having a vlan.')
        return

    if ip and not vlan:
        gandi.echo('You must have a --vlan when giving an --ip.')
        return

    vm_ = gandi.iaas.info(attach) if attach else None

    if datacenter and vm_:
        dc_id = gandi.datacenter.usable_id(datacenter)
        if dc_id != vm_['datacenter_id']:
            gandi.echo('The datacenter you provided does not match the '
                       'datacenter of the vm you want to attach to.')
            return

    if not datacenter:
        datacenter = vm_['datacenter_id'] if vm_ else 'LU'

    try:
        gandi.datacenter.is_opened(datacenter, 'iaas')
    except DatacenterLimited as exc:
        gandi.echo('/!\ Datacenter %s will be closed on %s, '
                   'please consider using another datacenter.' %
                   (datacenter, exc.date))

    return gandi.ip.create(ip_version, datacenter, bandwidth, attach,
                           vlan, ip, background)
1362157
def create_networks(self, ids, id_vlan):
        

        network_map = dict()
        network_map['ids'] = ids
        network_map['id_vlan'] = id_vlan

        code, xml = self.submit(
            {'network': network_map}, 'PUT', 'network/create/')

        return self.response(code, xml)
379351
def _create_vlanprofile(self, handle, vlan_id, ucsm_ip):
        """"""
        vlan_name = self.make_vlan_name(vlan_id)
        vlan_profile_dest = (const.VLAN_PATH + const.VLAN_PROFILE_PATH_PREFIX +
                             vlan_name)

        try:
            vp1 = handle.query_dn(const.VLAN_PATH)
            if not vp1:
                LOG.warning('UCS Manager network driver Vlan Profile '
                            'path at %s missing', const.VLAN_PATH)
                return False

            # Create a vlan profile with the given vlan_id
            vp2 = self.ucsmsdk.fabricVlan(
                parent_mo_or_dn=vp1,
                name=vlan_name,
                compression_type=const.VLAN_COMPRESSION_TYPE,
                sharing=const.NONE,
                pub_nw_name="",
                id=str(vlan_id),
                mcast_policy_name="",
                default_net="no")

            handle.add_mo(vp2)
            handle.commit()

            if vp2:
                LOG.debug('UCS Manager network driver Created Vlan '
                          'Profile %s at %s', vlan_name, vlan_profile_dest)
                return True

        except Exception as e:
            return self._handle_ucsm_exception(e, 'Vlan Profile',
                                               vlan_name, ucsm_ip)
9633
def ifaces(cls, name):
        
        ifaces = Iface.list({'vlan_id': cls.usable_id(name)})
        ret = []
        for iface in ifaces:
            ret.append(Iface.info(iface['id']))
        return ret