def couple_uncouple_nic(self, userid, vdev, body): info = body['info'] active = info.get('active', False) active = util.bool_from_string(active, strict=True) couple = util.bool_from_string(info['couple'], strict=True) if couple: self.api.guest_nic_couple_to_vswitch(userid, vdev, info['vswitch'], active=active) else: self.api.guest_nic_uncouple_from_vswitch(userid, vdev, active=active)
def create(self, body): vsw = body['vswitch'] name = vsw['name'] rdev = vsw.get('rdev', None) controller = vsw.get('controller', '*') connection = vsw.get('connection', "CONNECT") network_type = vsw.get('network_type', "IP") router = vsw.get('router', "NONROUTER") vid = vsw.get('vid', "UNAWARE") port_type = vsw.get('port_type', "ACCESS") gvrp = vsw.get('gvrp', "GVRP") queue_mem = vsw.get('queue_mem', 8) native_vid = vsw.get('native_vid', 1) persist = vsw.get('persist', True) persist = util.bool_from_string(persist, strict=True) info = self.client.send_request('vswitch_create', name, rdev=rdev, controller=controller, connection=connection, network_type=network_type, router=router, vid=vid, port_type=port_type, gvrp=gvrp, queue_mem=queue_mem, native_vid=native_vid, persist=persist) return info
def delete_nic(self, userid, vdev, body): active = body.get('active', False) active = util.bool_from_string(active, strict=True) info = self.client.send_request('guest_delete_nic', userid, vdev, active=active) return info
def nic_couple_uncouple(self, userid, vdev, body): info = body['info'] active = info.get('active', False) active = util.bool_from_string(active, strict=True) couple = util.bool_from_string(info['couple'], strict=True) if couple: info = self.client.send_request('guest_nic_couple_to_vswitch', userid, vdev, info['vswitch'], active=active) else: info = self.client.send_request('guest_nic_uncouple_from_vswitch', userid, vdev, active=active) return info
def delete_network_interface(self, userid, body=None): interface = body['interface'] version = interface['os_version'] vdev = interface['vdev'] active = interface.get('active', False) active = util.bool_from_string(active, strict=True) info = self.client.send_request('guest_delete_network_interface', userid, version, vdev, active=active) return info
def create_network_interface(self, userid, body=None): interface = body['interface'] version = interface['os_version'] networks = interface.get('guest_networks', None) active = interface.get('active', False) active = util.bool_from_string(active, strict=True) info = self.client.send_request('guest_create_network_interface', userid, os_version=version, guest_networks=networks, active=active) return info
def nic_couple_uncouple(self, userid, vdev, body): info = body['info'] active = info.get('active', False) active = util.bool_from_string(active, strict=True) couple = util.bool_from_string(info['couple'], strict=True) # vlan_id is for couple operation only, uncouple ignore it vlan_id = info.get('vlan_id', -1) if couple: info = self.client.send_request('guest_nic_couple_to_vswitch', userid, vdev, info['vswitch'], active=active, vlan_id=vlan_id) else: info = self.client.send_request('guest_nic_uncouple_from_vswitch', userid, vdev, active=active) return info
def create_nic(self, userid, body=None): nic = body['nic'] vdev = nic.get('vdev', None) nic_id = nic.get('nic_id', None) mac_addr = nic.get('mac_addr', None) active = nic.get('active', False) active = util.bool_from_string(active, strict=True) info = self.client.send_request('guest_create_nic', userid, vdev=vdev, nic_id=nic_id, mac_addr=mac_addr, active=active) return info