Esempio n. 1
0
 def add_loadgroup(self, ip, managedsystem_uuid, session_id, networkbridge_object, virtualnetwork_object):
     """
     addition of a Loadgroup
     Args:
         ip:ip address of hmc
         managedsystem_uuid:UUID of the managedsystem
         session_id:session to be used
         networkbridge_object:networkbridge object to be modified
         vrtualnetwork_object:virtual network object on which Loadgroup is to be added
     Returns:
          boolen value
     """
     log.log_debug("addition of load group started")
     link = "https://"+ip+":12443/rest/api/uom/ManagedSystem/"+managedsystem_uuid+"/VirtualNetwork/"+virtualnetwork_object.Metadata.Atom.AtomID.value()
     loadgroup_object = UOM.LoadGroup()
     loadgroup_object.PortVLANID = virtualnetwork_object.NetworkVLANID.value()
     loadgroup_object.VirtualNetworks = pyxb.BIND()
     loadgroup_object.VirtualNetworks.link.append(UOM.AtomLink_Type(rel="related",href=link))
     loadgroup_object.schemaVersion = SCHEMA_VER
     networkbridge_object.LoadGroups.LoadGroup.append(loadgroup_object)
     xml = networkbridge_object.toxml()
     httpclient_object = HTTPClient.HTTPClient("uom",ip,self.root,self.content_type,session_id)
     httpclient_object.HTTPPost(xml,append=str(managedsystem_uuid)+"/NetworkBridge/"+networkbridge_object.Metadata.Atom.AtomID.value())
     log.log_debug("reponse for addition of loadgroup -- %s"%(httpclient_object.response))
     if  httpclient_object.response_b:
         return True
     else:
         return False
Esempio n. 2
0
 def create_volumegroup(self, ip, virtualioserver_uuid, x_api_session):
     """
     Args:
         ip:ip address of hmc
         virtualioserver_uuid:UUID of VirtualIOServer
         x_api_session:session to be used
     """
     log.log_debug("create volume group started")
     pyxb.RequireValidWhenGenerating(True)
     volumegroup_object = UOM.VolumeGroup()
     volumegroup_object.schemaVersion = SCHEMA_VER
     volumegroup_object.GroupName = VOLUMEGROUP_NAME
     physicalvolume_object = UOM.PhysicalVolume()
     physicalvolume_object.VolumeName = PHYSICALVOLUME_NAME
     physicalvolume_object.schemaVersion = SCHEMA_VER
     volumegroup_object.PhysicalVolumes = pyxb.BIND()
     volumegroup_object.PhysicalVolumes.schemaVersion = SCHEMA_VER
     volumegroup_object.PhysicalVolumes.append(physicalvolume_object)
     xml = volumegroup_object.toxml()
     http_object = HTTPClient.HTTPClient("uom", ip, self.root,
                                         self.content_type, x_api_session)
     http_object.HTTPPut(xml, append=virtualioserver_uuid + "/VolumeGroup")
     log.log_debug("response of volume group creation -- %s" %
                   (http_object.response))
     if http_object.response_b:
         print("VolumeGroup Created Successfully")
         log.log_debug("VolumeGroup Created Successfully")
     else:
         log.log_error(
             "Error in VolumeGroup creation.Verify the attribute values")
Esempio n. 3
0
    def create_cluster(self, ip, x_api_session, vios_id):
        """
        xml for cluster and shared storage pool are created
        from python objects and are inserted in to job request
        input xml.
        Args:
            ip:ip address of hmc
            x_api_session:session used to create cluster
            vios_id:UUID of vios to be added to the cluster
        """
        super().__init__(ip, self.root, self.content_type, x_api_session)
        log.log_debug("Invoking create cluster")
        directory = os.path.dirname(__file__) + "/data/create_cluster.xml"
        xml = open(directory).read()
        link = "https://" + ip + ":12443/rest/api/uom/VirtualIOServer/" + vios_id
        log.log_debug("Link of vios to be added to cluster %s" % (link))
        cluster_object = UOM.Cluster()
        cluster_object.ClusterName = CLUSTER_NAME % (
            time.strftime("%d%m%y-%X"))
        cluster_object.schemaVersion = SCHEMA_VER

        physicalvolume_object = UOM.PhysicalVolume()
        physicalvolume_object.VolumeName = PHYSICAL_VOLUME_REPODISK
        physicalvolume_object.schemaVersion = SCHEMA_VER
        cluster_object.RepositoryDisk = pyxb.BIND()
        cluster_object.RepositoryDisk.schemaVersion = SCHEMA_VER
        cluster_object.RepositoryDisk.PhysicalVolume.append(
            physicalvolume_object)

        cluster_object.Node = pyxb.BIND()
        node_object = UOM.Node()
        node_object.HostName = HOST_NAME
        node_object.VirtualIOServer = pyxb.BIND()
        node_object.VirtualIOServer.href = link
        node_object.VirtualIOServer.rel = "related"
        node_object.schemaVersion = SCHEMA_VER
        cluster_object.Node.schemaVersion = SCHEMA_VER
        cluster_object.Node.Node.append(node_object)
        cluster_xml = cluster_object.toxml()

        ssp_object = UOM.SharedStoragePool()
        ssp_object.schemaVersion = SCHEMA_VER
        physicalvolume_object.VolumeName = PHYSICAL_VOLUME_SSP1
        ssp_object.PhysicalVolumes = pyxb.BIND()
        ssp_object.PhysicalVolumes.schemaVersion = SCHEMA_VER
        ssp_object.PhysicalVolumes.PhysicalVolume.append(physicalvolume_object)
        physicalvolume_object.VolumeName = PHYSICAL_VOLUME_SSP2
        ssp_object.PhysicalVolumes.PhysicalVolume.append(physicalvolume_object)
        ssp_object.StoragePoolName = POOL_NAME
        sspxml = ssp_object.toxml()

        xml = xml % (cluster_xml, sspxml)

        http_object = HTTPClient.HTTPClient("uom", ip, self.root,
                                            self.content_type, x_api_session)
        http_object.HTTPPut(xml, append="/do/create")
        log.log_debug("HTTP response for creating cluster -- %s" %
                      (http_object.response))
        if http_object.response_b:
            self.get_job_status(http_object)
 def create_clientnetwork_adapter(self, ip, logicalpartition_id,
                                  x_api_session):
     """
     Args:
        ip:ip address of the hmc
        logicalpartition_id:the uuid of the logical partition on which network adapter
        is to be created
        x_api_session:session used to create network adapter
     """
     log.log_debug("create client network adapter starting")
     pyxb.RequireValidWhenGenerating(True)
     clientnetwork_adapter_object = UOM.ClientNetworkAdapter()
     clientnetwork_adapter_object.PortVLANID = PORT_VLAN_ID
     clientnetwork_adapter_object.schemaVersion = SCHEMA_VER
     xml = clientnetwork_adapter_object.toxml()
     http_object = HTTPClient.HTTPClient("uom", ip, self.root,
                                         self.content_type, x_api_session)
     http_object.HTTPPut(xml,
                         append=logicalpartition_id +
                         "/ClientNetworkAdapter")
     log.log_debug("response of create client network adapter --- %s" %
                   (http_object.response))
     if http_object.response_b:
         print("ClientNetworkAdapter Created successfully")
         log.log_debug("ClientNetworkAdapter Created successfully")
     else:
         log.log_error("Error in ClientNetworkAdapter Creation")
Esempio n. 5
0
 def add_node(self, ip, x_api_session, cluster_object, vios_id):
     """
     Args:
         ip: ip address of hmc
         x_api_session: session to be used for adding a node
         cluster_object:cluster object into which the node is to be added
         vios_id:UUID of the vios to be added
     """
     log.log_debug("adding a node to a cluster process starting")
     link = "https://" + ip + ":12443/rest/api/uom/VirtualIOServer/" + vios_id
     log.log_debug("vios to be added to the cluster -- %s" % (link))
     node_object = UOM.Node()
     node_object.HostName = NODE_HOST_NAME
     node_object.VirtualIOServer = pyxb.BIND()
     node_object.VirtualIOServer.href = link
     node_object.VirtualIOServer.rel = "related"
     node_object.schemaVersion = SCHEMA_VER
     cluster_object.Node.schemaVersion = SCHEMA_VER
     cluster_object.Node.Node.append(node_object)
     cluster_xml = cluster_object.toxml()
     cluster_id = cluster_object.Metadata.Atom.AtomID.value()
     http_object = HTTPClient.HTTPClient("uom", ip, self.root,
                                         self.content_type, x_api_session)
     http_object.HTTPPost(cluster_xml, append=cluster_id)
     log.log_debug("response for adding a node to cluster --- %s" %
                   (http_object.response))
     if http_object.response_b:
         print("Node is added to the cluster successfully")
         log.log_debug("node added successfully")
     else:
         log.log_error("Error occured while adding a node to the cluster")
Esempio n. 6
0
 def create_sriov_logicalport(self, ip, logicalpartition_uuid, x_api_session):
     """
     Creates SRIOV Logical Port for a given LogicaPartition
     Args:
         ip:ip address of hmc
         logicalpartition_uuid : UUID of partition the LoicalPort to be created
         x_api_session :session to be used
     """
     log.log_debug("starting SRIOV LogicalPort creation")
     header_object = HmcHeaders.HmcHeaders("web")
     ns = header_object.ns["xmlns"]
     sriov_logical_port_object = UOM.SRIOVEthernetLogicalPort()
     sriov_logical_port_object.AdapterID = ADAPTER_ID
     sriov_logical_port_object.PhysicalPortID = PHYSICALPORT_ID
     sriov_logical_port_object.schemaVersion = SCHEMA_VER
     xml = sriov_logical_port_object.toxml()
     http_object = HTTPClient.HTTPClient("uom", ip, self.root, self.content_type, x_api_session)
     http_object.HTTPPut(xml, append = logicalpartition_uuid+"/SRIOVEthernetLogicalPort")
     log.log_debug("response of SRIOV logical port creation %s"%(http_object.response))
     if http_object.response_b:
         print("SRIOV Logical Port created successfully")
     else :
         root = etree.fromstring(http_object.response.content)
         error = root.findall(".//{%s}Message"%(ns))[0]
         log.log_error(error.text)
 def create_vscsi_clientadapter(self, ip, logicalpartition_uuid,
                                x_api_session):
     """
     Args:
         ip: ip address of hmc
         logicalpartition_uuid:UUID of Logical partition on which virtual SCSI
         adapter is to be created
         x_api_session:session used to create virtual SCSI adapter
     """
     log.log_debug("creation of scsi adapter started")
     vscsi_object = UOM.VirtualSCSIClientAdapter()
     vscsi_object.AdapterType = ADAPTER_TYPE
     vscsi_object.RemoteLogicalPartitionID = PARTITION_ID
     vscsi_object.RemoteSlotNumber = SLOT_NUMBER
     vscsi_object.schemaVersion = SCHEMA_VER
     pyxb.RequireValidWhenGenerating(True)
     xml = vscsi_object.toxml()
     http_object = HTTPClient.HTTPClient("uom", ip, self.root,
                                         self.content_type, x_api_session)
     http_object.HTTPPut(xml,
                         append=logicalpartition_uuid +
                         "/VirtualSCSIClientAdapter")
     log.log_debug("response of create scsi adapter --- %s" %
                   (http_object.response))
     if http_object.response_b:
         print("VirtualSCSIClientAdapter created successfully")
         log.log_debug("VirtualSCSIClientAdapter created successfully")
     else:
         log.log_error(
             "Error in VirtualSCSIClientAdapter creation.Verify the attribute values"
         )
Esempio n. 8
0
 def add_virtualdisk(self, ip, vios_uuid, x_api_session,
                     volumegroup_object):
     """
      creates a virtualdisk in VolumeGroup
      Args:
         ip:ip address of hmc
         vios_uuid:UUID of VirtualIOServer
         x_api_session:session to be used
         volumegroup_object:volume group object to be modified
      """
     pyxb.RequireValidWhenGenerating(True)
     virtualdisk_object = UOM.VirtualDisk()
     virtualdisk_object.DiskName = LOGICALVOLUME_NAME
     virtualdisk_object.schemaVersion = SCHEMA_VERSION
     virtualdisk_object.DiskCapacity = volumegroup_object.GroupCapacity.value(
     ) / 2
     volumegroup_object.VirtualDisks.VirtualDisk.append(virtualdisk_object)
     xml = volumegroup_object.toxml()
     volumegroup_id = volumegroup_object.Metadata.Atom.AtomID.value()
     response = sendrequest(xml, ip, self.root, self.content_type,
                            x_api_session, vios_uuid, volumegroup_id)
     if response:
         print("VirtualDisk Created in VolumeGroup Successfully")
     else:
         print("VirtualDisk Creation unsuccessfull")
Esempio n. 9
0
    def add_physicalvolume(self, ip, vios_uuid, x_api_session,
                           volumegroup_object):
        """ 
            adds a Physical volume to the selected volume group
            Args:
               ip:ip address of hmc
               vios_uuid:UUID of VirtualIOServer
               x_api_session:session to be used
               volumegroup_object:volume group object to be modified
            """
        pyxb.RequireValidWhenGenerating(True)
        physicalvolume_object = UOM.PhysicalVolume()

        physicalvolume_object.VolumeName = PHYSICALVOLUME_NAME
        physicalvolume_object.schemaVersion = SCHEMA_VERSION
        volumegroup_object.PhysicalVolumes.PhysicalVolume.append(
            physicalvolume_object)
        xml = volumegroup_object.toxml()
        volumegroup_id = volumegroup_object.Metadata.Atom.AtomID.value()
        response = sendrequest(xml, ip, self.root, self.content_type,
                               x_api_session, vios_uuid, volumegroup_id)
        if response:
            print("Physical volume added to volumegroup Successfully")
        else:
            print("Adding Physical volume to volumegroup failed")
Esempio n. 10
0
 def create_virtualnetwork(self, ip, managedsystem_uuid, x_api_session, virtualswitch_object):
     """
     create a virtual network in a given managed system
     Args:
         ip:ip address of hmc
         managedsystem_uuid:UUID of managedsystem
         x_api_session:session to be used
         virtualswitch_object:Virtual switch object to be used for virtual network
     Returns:
         boolean value
     """
     log.log_debug("virtual network creation started")
     pyxb.RequireValidWhenGenerating(True)
     virtual_network_object = UOM.VirtualNetwork()
     virtual_network_object.schemaVersion = SCHEMA_VER
     virtual_network_object.AssociatedSwitch = pyxb.BIND()
     virtual_network_object.AssociatedSwitch.href = "https://%s:12443/rest/api/uom/ManagedSystem/%s/VirtualSwitch/%s"\
                                                    %(ip,managedsystem_uuid,virtualswitch_object.Metadata.Atom.AtomID.value())
     virtual_network_object.AssociatedSwitch.rel = "related"
     virtual_network_object.NetworkVLANID = NETWORK_VLAN_ID 
     virtual_network_object.NetworkName = "VLAN%s-%s"%(virtual_network_object.NetworkVLANID.value(),virtualswitch_object.SwitchName.value())
     virtual_network_object.VswitchID = virtualswitch_object.SwitchID.value()
     virtual_network_object.TaggedNetwork = TAGGED_NETWORK
     xml = virtual_network_object.toxml()
     http_object = HTTPClient.HTTPClient("uom",ip,self.root,self.content_type,x_api_session)
     http_object.HTTPPut(xml,append=managedsystem_uuid+"/VirtualNetwork")
     log.log_debug("virtualnetwork creation response -- %s"%(http_object.response))
     if http_object.response_b:
         return True
     else :
         return False
 def create_LogicalPartitionProfile(self, ip, logicalpartition_object,
                                    session_id):
     """
     Assign values to the profile object and creates the profile to the given vios
     Args:
        ip : ip address of hmc
        logicalpartition_object : VIOS/Logical Partition object on which
                                  profile should be created
        session_id : session to be used
     """
     log_object.log_debug("creation of lpar profile started")
     ns = self.headers_obj.ns
     logicalpartitionprofile_object = UOM.LogicalPartitionProfile()
     pyxb.RequireValidWhenGenerating(True)
     logicalpartitionprofile_object.ProfileName = PROFILE_NAME % (
         time.strftime("%d%m%y-%X"))
     logicalpartitionprofile_object.ProfileType = PROFILE_TYPE
     logicalpartitionprofile_object.schemaVersion = SCHEMA_VER
     logicalpartitionprofile_object.ProfileMemory = pyxb.BIND()
     logicalpartitionprofile_object.ProfileMemory.schemaVersion = SCHEMA_VER
     logicalpartitionprofile_object.ProfileMemory.MaximumMemory = MAX_MEMORY
     logicalpartitionprofile_object.ProfileMemory.MinimumMemory = MIN_MEMORY
     logicalpartitionprofile_object.ProfileMemory.DesiredMemory = DES_MEMORY
     xmlobject = logicalpartitionprofile_object.toDOM()
     xmlobject.documentElement.setAttribute("xmlns", ns["xmlns"])
     xmlpayload = xmlobject.toxml("utf-8")
     HTTPClient_object = HTTPClient.HTTPClient("uom", ip, self.root,
                                               self.content_type,
                                               session_id)
     HTTPClient_object.HTTPPut(
         payload=xmlpayload,
         append=str(logicalpartition_object.PartitionUUID.value()) +
         "/LogicalPartitionProfile")
     log_object.log_debug("response of profile creation -- %s" %
                          (HTTPClient_object.response))
     if HTTPClient_object.response_b:
         root = etree.fromstring(HTTPClient_object.response.content)
         entry = root.findall(
             ".//LogicalPartitionProfile:LogicalPartitionProfile",
             namespaces={"LogicalPartitionProfile": ns["xmlns"]})
         xmlstring = etree.tostring(entry[0])
         xml_object = UOM.CreateFromDocument(xmlstring)
         log_object.log_debug("created partition successfully")
         return xml_object
     else:
         log_object.log_error("Error in Profile creation")
Esempio n. 12
0
 def create_virtualswitch(self, ip, managedsystem_uuid, x_api_session):
     """
     Args:
         ip:ip address of hmc
         managedsystem_uuid:UUID of managedsystem
         x_api_session:session to be used
     """
     log.log_debug("creation of virtual switch started")
     pyxb.RequireValidWhenGenerating(True)
     virtualswitch_object = UOM.VirtualSwitch()
     virtualswitch_object.schemaVersion = SCHEMA_VER
     virtualswitch_object.SwitchName = SWITCH_NAME
     xml = virtualswitch_object.toxml()
     http_object = HTTPClient.HTTPClient("uom",ip,self.root,self.content_type,x_api_session)
     http_object.HTTPPut(xml,append=managedsystem_uuid+"/VirtualSwitch")
     log.log_debug("response for creation of virtual switch -- %s"%(http_object.response))
     if http_object.response_b:
         return True
     else:
         return False
Esempio n. 13
0
 def list_sriov_physicalport(self, ip, managedsystem_uuid, x_api_session):
     """
     returns the list of SRIOV Ethernet Physical Port Availble in the system
     Args:
         ip : ip address of HMC
         managedsystem_uuid : UUID of ManagedSystem from which SRIOV physical Ports are listed
         x_api_session : session to be used
     """
     object_list = []  
     header_object = HmcHeaders.HmcHeaders("uom")
     ns = header_object.ns["xmlns"]
     http_object = HTTPClient.HTTPClient("uom", ip, self.root, self.content_type,x_api_session)
     http_object.HTTPGet(append=managedsystem_uuid)
     log.log_debug("List of SRIOV Ethernet Physical Port is returned")
     if http_object.response_b:
         root = etree.fromstring(http_object.response.text)
         entries = root.findall(".//{%s}SRIOVEthernetPhysicalPort"%(ns))
         for entry in entries:
             xmlstring = etree.tostring(entry)
             xml_object = UOM.CreateFromDocument(xmlstring)
             object_list.append(xml_object)
     return object_list
 def create_virtualfibrechannel_mapping(self, ip, managedsystem_uuid,
                                        x_api_session, vios_object,
                                        lpar_id):
     """
     creates a virtual fibre mapping between given vios object and lpar
     Args:
         ip:ip address of hmc
         managedsystem_uuid:UUID of VirtualIOServer
         x_api_session:session to be used
         vios_object:vios object in which mapping is created
         lpar_id:UUID of logical partition to which mapping is created
     """
     log.log_debug("creation of fc mapping started")
     pyxb.RequireValidWhenGenerating(True)
     lpar_link = "https://" + ip + ":12443/rest/api/uom/ManagedSystem/" + managedsystem_uuid + "/LogicalPartition/" + lpar_id
     virtualfibrechannel_mapping_object = UOM.VirtualFibreChannelMapping()
     virtualfibrechannel_mapping_object.AssociatedLogicalPartition = pyxb.BIND(
     )
     virtualfibrechannel_mapping_object.AssociatedLogicalPartition.href = lpar_link
     virtualfibrechannel_mapping_object.AssociatedLogicalPartition.rel = "related"
     virtualfibrechannel_mapping_object.Port = pyxb.BIND()
     virtualfibrechannel_mapping_object.Port.PortName = FIBRE_CHANNEL_PORT_NAME
     virtualfibrechannel_mapping_object.Port.schemaVersion = SCHEMA_VER
     virtualfibrechannel_mapping_object.schemaVersion = SCHEMA_VER
     vios_object.VirtualFibreChannelMappings.append(
         virtualfibrechannel_mapping_object)
     xml = vios_object.toxml()
     http_object = HTTPClient.HTTPClient("uom", ip, self.root,
                                         self.content_type, x_api_session)
     http_object.HTTPPost(xml,
                          append=vios_object.Metadata.Atom.AtomID.value())
     log.log_debug("response of fc mapping creation -- %s" %
                   (http_object.response))
     if http_object.response_b:
         print("\nVirtual FibreChannel Mapping created successfully")
     else:
         log.log_error(
             "\nError in creation of FibreChannelMapping.Verify the attribute values"
         )
Esempio n. 15
0
 def listing(self, service, ip, root, content_type, Resource, session_id, uuid=None):
     
      """
      Makes an HTTPRequest to get the details of the
      corresponding object and store the response content
      into a python object.
      Args:
          service:uom or web
          ip:ip address of the hmc
          root:root element in rest uri
          content_type:type of object to be extracted
                       (logicalpartition,logicalpartitionprofile,
                        ManagedSystem,VirtualIOServer and other objects)
          session_id:to access the session
          uuid:root unique id
      Returns:
          list of corresponding objects
      """
      #for ManagementConsole the uuid is none and for other types the uri is appended with roots uuid
      obj_list = []
      xml_object = None
      headers_obj = HmcHeaders.HmcHeaders(service)
      ns = headers_obj.ns
      request_obj = HTTPClient.HTTPClient(service, ip, root, content_type, session_id)
      if uuid == None:
          request_obj.HTTPGet()
      else:
          request_obj.HTTPGet(append=str(uuid)+"/"+Resource)
      if request_obj.response_b:
          root = etree.fromstring(request_obj.response.text)
          entries = root.findall(".//%s:%s"%(Resource,Resource),
                              namespaces={"%s" %(Resource): ns["xmlns"]})
          for entry in entries:
              if entry.getchildren() != []:
                  xmlstring = etree.tostring(entry)
                  xml_object = UOM.CreateFromDocument(xmlstring)
                  obj_list.append(xml_object)
          return obj_list
Esempio n. 16
0
 def add_vlan_to_loadgroup(self, ip, managedsystem_uuid, session_id, networkbridge_object, virtualnetwork_id):
     """
     additional VLAN to exiting Loadgroup
     Args:
         ip:ip address of hmc
         managedsystem_uuid:UUID of the managedsystem
         session_id:session to be used
         networkbridge_object:networkbridge object to be modified
         vrtualnetwork_id:UUID of the virtual network to be added
     Returns:
          boolen value
     """
     log.log_debug("addition of vlan to load group started")
     link = "https://"+ip+":12443/rest/api/uom/ManagedSystem/"+managedsystem_uuid+"/VirtualNetwork/"+virtualnetwork_id
     networkbridge_object.LoadGroups.LoadGroup[0].VirtualNetworks.link.append(UOM.AtomLink_Type(rel="related",href=link))
     xml = networkbridge_object.toxml()
     httpclient_object = HTTPClient.HTTPClient("uom",ip,self.root,self.content_type,session_id)
     httpclient_object.HTTPPost(xml,append=str(managedsystem_uuid)+"/NetworkBridge/"+networkbridge_object.Metadata.Atom.AtomID.value())
     log.log_debug("reponse for addition of vlan -- %s"%(httpclient_object.response))
     if  httpclient_object.response_b:
         return True
     else:
         return False
Esempio n. 17
0
 def create_vscsi_mapping(self, ip, managedsystem_uuid, x_api_session,
                          virtualioserver_object, logicalPartition_id):
     """
     Creates a Virtual SCSI mapping between seleced vios and lpar
     Args:
         ip:ip address of hmc
         managedsystem_uuid:UUID of VirtualIOServer
         x_api_session:session to be used
         virtualioserver_object:vios object in which mapping is created
         logicalPartition_id:UUID of logical partition to which mapping is created
     """
     log.log_debug("create vscsi mapping started")
     logicalpartition_link = "http://" + ip + ":12443/rest/api/uom/ManagedSystem/" + managedsystem_uuid + "/LogicalPartition/" + logicalPartition_id
     pyxb.RequireValidWhenGenerating(True)
     vscsi_mapping_object = UOM.VirtualSCSIMapping()
     vscsi_mapping_object.Storage = pyxb.BIND()
     vscsi_mapping_object.Storage.PhysicalVolume = pyxb.BIND()
     vscsi_mapping_object.Storage.PhysicalVolume.schemaVersion = SCHEMA_VER
     vscsi_mapping_object.Storage.PhysicalVolume.VolumeName = PHYSICALVOLUME_NAME
     vscsi_mapping_object.schemaVersion = SCHEMA_VER
     vscsi_mapping_object.AssociatedLogicalPartition = pyxb.BIND()
     vscsi_mapping_object.AssociatedLogicalPartition.href = logicalpartition_link
     vscsi_mapping_object.AssociatedLogicalPartition.rel = "related"
     virtualioserver_object.VirtualSCSIMappings.VirtualSCSIMapping.append(
         vscsi_mapping_object)
     virtualioserver_id = virtualioserver_object.Metadata.Atom.AtomID.value(
     )
     xml = virtualioserver_object.toxml()
     http_object = HTTPClient.HTTPClient("uom", ip, self.root,
                                         self.content_type, x_api_session)
     http_object.HTTPPost(xml, append=virtualioserver_id)
     log.log_debug("response of scsi mapping creation -- %s" %
                   (http_object.response))
     if http_object.response_b:
         print("VSCSIMapping Created Successfully")
     else:
         log.log_error("Error in VSCSIMapping.Verify the attribute values")
Esempio n. 18
0
    def create_network_bridge(self, ip, managedsystem_uuid, session_id,
                              vios_uuid, virtual_network_uuid):
        """
        creates a network bridge in a given managed system.
        Args:
            ip:ip address of hmc
            managedsystem_uuid:UUID of managed system
            session_id:session to be used
            vios_uuid:UUID of vios to create trunk and shared ethernet adapter
            virtual_network_uuid:UUID of virtual network on which network bridge is to be created
        """
        log.log_debug("creation of network bridge started")
        link = "https://%s:12443/rest/api/uom/ManagedSystem/%s/%s"
        vios_link = link % (ip, managedsystem_uuid,
                            "VirtualIOServer/" + vios_uuid)
        virtual_network_link = link % (
            ip, managedsystem_uuid, "VirtualNetwork/" + virtual_network_uuid)
        ns = self.headers_obj.ns
        pyxb.RequireValidWhenGenerating(True)
        network_bridge_object = UOM.NetworkBridge()
        network_bridge_object.schemaVersion = SCHEMA_VER
        network_bridge_object.FailoverEnabled = FAILOVER_ENABLED
        network_bridge_object.LoadBalancingEnabled = LOADBALANCING_ENABLED
        network_bridge_object.LoadGroups = pyxb.BIND()
        virtual_network = UOM.VirtualNetwork_Links_Type()
        virtual_network.link.append(
            UOM.AtomLink_Type(rel="related", href=virtual_network_link))

        load_groups_obj = UOM.LoadGroup()
        load_groups_obj.PortVLANID = LOADGROUP_PORT_VLAN_ID
        load_groups_obj.schemaVersion = SCHEMA_VER
        load_groups_obj.VirtualNetworks = pyxb.BIND()
        load_groups_obj.VirtualNetworks.link = virtual_network.link
        network_bridge_object.LoadGroups = pyxb.BIND(load_groups_obj,
                                                     schemaVersion="V1_3_0")

        network_bridge_object.SharedEthernetAdapters = pyxb.BIND()
        sea_obj = UOM.SharedEthernetAdapter()
        sea_obj.schemaVersion = SCHEMA_VER
        sea_obj.AssignedVirtualIOServer = pyxb.BIND()
        sea_obj.AssignedVirtualIOServer.href = vios_link
        sea_obj.AssignedVirtualIOServer.rel = "related"
        sea_obj.BackingDeviceChoice = pyxb.BIND()
        sea_obj.BackingDeviceChoice.EthernetBackingDevice = pyxb.BIND()
        sea_obj.BackingDeviceChoice.EthernetBackingDevice.schemaVersion = SCHEMA_VER
        sea_obj.BackingDeviceChoice.EthernetBackingDevice.AdapterID = BACKINGDEVICE_ADAPTER_ID
        sea_obj.BackingDeviceChoice.EthernetBackingDevice.DeviceName = BACKINGDEVICE_NAME
        sea_obj.PortVLANID = SEA_PORT_VLAN_ID
        sea_obj.IsPrimary = SEA_IS_PRIMARY
        network_bridge_object.SharedEthernetAdapters = pyxb.BIND(
            sea_obj, schemaVersion="V1_3_0")

        network_bridge_object.PortVLANID = NETWORK_BRIDGE_PVLANID
        network_bridge_object.VirtualNetworks = pyxb.BIND()
        virtual_network = UOM.VirtualNetwork_Links_Type()
        virtual_network.link.append(
            UOM.AtomLink_Type(rel="related", href=virtual_network_link))
        network_bridge_object.VirtualNetworks.link = virtual_network.link

        xmlobject = network_bridge_object.toDOM()
        xmlobject.documentElement.setAttribute("xmlns", ns["xmlns"])
        xmlpayload = xmlobject.toxml("utf-8")
        request_obj = HTTPClient.HTTPClient("uom", ip, self.root,
                                            self.content_type, session_id)
        request_obj.HTTPPut(xmlpayload,
                            append=str(managedsystem_uuid) + "/NetworkBridge")
        log.log_debug("response of network bridge creation -- %s" %
                      (request_obj.response))
        if request_obj.response_b:
            root = etree.fromstring(request_obj.response.content)
            entry = root.findall(".//NetworkBridge:NetworkBridge",
                                 namespaces={"NetworkBridge": ns["xmlns"]})
            xmlstring = etree.tostring(entry[0])
            xml_object = UOM.CreateFromDocument(xmlstring)
            return xml_object