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. 2
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
Esempio n. 3
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
    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