Ejemplo n.º 1
0
 def get_vlan(self, vlan_name=None):
     json_scheme = self.gen_def_json_scheme('GetPurchasedVLans')
     json_obj = self.call_method_post(method='GetPurchasedVLans', json_scheme=json_scheme)
     if vlan_name is not None:
         raw_vlans = filter(lambda x: vlan_name in x['Name'], json_obj['Value'])
     else:
         raw_vlans = json_obj['Value']
     vlans = []
     for raw_vlan in raw_vlans:
         v = Vlan()
         v.name = raw_vlan['Name']
         v.vlan_code = raw_vlan['VlanCode']
         v.resource_id = raw_vlan['ResourceId']
         vlans.append(v)
     return vlans
Ejemplo n.º 2
0
 def get_vlan(self, vlan_name=None):
     json_scheme = self.gen_def_json_scheme('GetPurchasedVLans')
     json_obj = self.call_method_post(method='GetPurchasedVLans',
                                      json_scheme=json_scheme)
     if vlan_name is not None:
         raw_vlans = filter(lambda x: vlan_name in x['Name'],
                            json_obj['Value'])
     else:
         raw_vlans = json_obj['Value']
     vlans = []
     for raw_vlan in raw_vlans:
         v = Vlan()
         v.name = raw_vlan['Name']
         v.vlan_code = raw_vlan['VlanCode']
         v.resource_id = raw_vlan['ResourceId']
         vlans.append(v)
     return vlans
Ejemplo n.º 3
0
 def purchase_vlan(self, vlan_name, debug=False):
     """
     Purchase a new VLAN.
     :param debug: Log the json response if True
     :param vlan_name: String representing the name of the vlan (virtual switch)
     :return: a Vlan Object representing the vlan created
     """
     vlan_name = {'VLanName': vlan_name}
     json_scheme = self.gen_def_json_scheme('SetPurchaseVLan', vlan_name)
     json_obj = self.call_method_post(method="SetPurchaseVLan", json_scheme=json_scheme)
     if debug is True:
         self.logger.debug(json_obj)
     if json_obj['Success'] is False:
         raise Exception("Cannot purchase new vlan.")
     vlan = Vlan()
     vlan.name = json_obj['Value']['Name']
     vlan.resource_id = json_obj['Value']['ResourceId']
     vlan.vlan_code = json_obj['Value']['VlanCode']
     return vlan
Ejemplo n.º 4
0
 def purchase_vlan(self, vlan_name, debug=False):
     """
     Purchase a new VLAN.
     :param debug: Log the json response if True
     :param vlan_name: String representing the name of the vlan (virtual switch)
     :return: a Vlan Object representing the vlan created
     """
     vlan_name = {'VLanName': vlan_name}
     json_scheme = self.gen_def_json_scheme('SetPurchaseVLan', vlan_name)
     json_obj = self.call_method_post(method="SetPurchaseVLan",
                                      json_scheme=json_scheme)
     if debug is True:
         self.logger.debug(json_obj)
     if json_obj['Success'] is False:
         raise Exception("Cannot purchase new vlan.")
     vlan = Vlan()
     vlan.name = json_obj['Value']['Name']
     vlan.resource_id = json_obj['Value']['ResourceId']
     vlan.vlan_code = json_obj['Value']['VlanCode']
     return vlan