def show(self, name, project, tenant, xml = False):
        '''
        This function will take consistency group name and project name as input and
        It will display the consistency group with details.
        parameters:
           name : Name of the consistency group.
           project: Name of the project.
        return
            returns with Details of consistency group. 
        '''
        uri = self.consistencygroup_query(name, project, tenant)
        (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", 
                                             self.URI_CONSISTENCY_GROUPS_INSTANCE.format(uri), None)
        o = common.json_decode(s)
        if( o['inactive']):
           return None

        if(xml == False):
            return o

        (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET",
                                             self.URI_CONSISTENCY_GROUPS_INSTANCE.format(uri), None, None, xml) 

        if not s:
            return None
        return s     
Пример #2
0
 def bucket_update(self, name, project, varray, softquota, hardquota, retention , tenant):
     '''
     update bucket with softquota , hardquota , retention
     Parameters:
         name      : Name of the bucket
         tenant    : name of tenant
         
     Returns:
         result of the action.
     '''
     
     parms = {}
     if(softquota):
         parms['soft_quota'] = softquota
         
     if(hardquota):
         parms['hard_quota'] = hardquota
         
     if(retention):
         parms['retention'] = retention
     if(name):
         bucket_uri = self.get_bucket_uri( tenant, project, name)
         
     body = json.dumps(parms)
    
     common.service_json_request(self.__ipAddr, self.__port, "PUT",
                                 Bucket.URI_BUCKET_SHOW.format(bucket_uri),
                                 body)
     return
Пример #3
0
    def exportgroup_show(self, name, project, tenant, xml=False):
        """
        This function will take export group name and project name as input and
        It will display the Export group with details.
        parameters:
           name : Name of the export group.
           project: Name of the project.
        return
            returns with Details of export group.
        """
        uri = self.exportgroup_query(name, project, tenant)
        (s, h) = common.service_json_request(
            self.__ipAddr, self.__port, "GET", self.URI_EXPORT_GROUPS_SHOW.format(uri), None
        )
        o = common.json_decode(s)
        if o["inactive"]:
            return None

        if not xml:
            return o

        (s, h) = common.service_json_request(
            self.__ipAddr, self.__port, "GET", self.URI_EXPORT_GROUPS_SHOW.format(uri), None, None, xml
        )

        return s
    def ps_show_uri(self, uri, xml=False):
        '''
        This function will take uri as input and returns with
        all parameters of RecoverPoint like lable, urn and type.
        parameters
            uri : unique resource identifier.
        return
            returns with object contain all details of Recovry Point.
        '''
        (s, h) = common.service_json_request(self.__ipAddr, self.__port,
                        "GET",
                        self.URI_PROTECTION_SYSTEM.format(uri), None, None)

        o = common.json_decode(s)
        if(o['inactive']):
            return None

        if(xml == False):
            return o

        (s, h) = common.service_json_request(self.__ipAddr, self.__port,
                        "GET",
                        self.URI_PROTECTION_SYSTEM.format(uri),
                        None, None, xml)
        return s
Пример #5
0
    def get_catalog(self, uriPath, xml=False):

        if (uriPath is None):
            uriPath = ""
        elif (uriPath.startswith("/") is False):
            uriPath = "/" + uriPath

        command = singletonURIHelperInstance.getUri(
            self.COMPONENT_TYPE, "catalog")
        port = self.__port
        if(len(uriPath) == 0):
            port = common.getenv('VIPR_UI_PORT')
        (s, h) = common.service_json_request(self.__ipAddr, port, "GET",
                                             command.format(uriPath),
                                             None)
        o = common.json_decode(s)
        inactive = common.get_node_value(o, 'inactive')

        if (inactive):
            return None
        if (xml):
            (s, h) = common.service_json_request(self.__ipAddr, port, "GET",
                                                 command.format(uriPath),
                                                 None, None, xml)
            return s
        else:
            return o
Пример #6
0
    def cluster_update(self, name, tenant, datacenter, vcenter, label):
        '''
        update cluster with datacenter, label
        Parameters:
            name      : Name of the cluster
            tenant    : name of tenant
            datacenter: Name of datacenter
            vcenter   : name of vcenter
            label     : new name to existing cluster
        Returns:
            result of the action.
        '''
        parms = {}
        # new name
        if(label):
            parms['name'] = label

        # datacenter
        if(datacenter):
            vdatacenterobj = VcenterDatacenter(self.__ipAddr, self.__port)
            data_uri = vdatacenterobj.vcenterdatacenter_query(
                datacenter, vcenter, tenant)
            parms['vcenter_data_center'] = data_uri

        # get the cluster uri
        cluster_uri = self.cluster_query(name, tenant)

        body = json.dumps(parms)
        common.service_json_request(self.__ipAddr, self.__port, "PUT",
                                    Cluster.URI_CLUSTER.format(cluster_uri),
                                    body)
        return
Пример #7
0
    def show_by_uri(self, uri, xml=False):
        '''
        Makes REST API call and retrieves network details based on UUID
        Parameters:
            uri: UUID of network
        Returns:
            Network details in JSON response payload
        '''

        (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET",
                                             Network.URI_NETWORK.format(uri),
                                             None)
        o = common.json_decode(s)
        if ('inactive' in o):
            if (o['inactive']):
                return None

        if (xml):
            (s,
             h) = common.service_json_request(self.__ipAddr, self.__port,
                                              "GET",
                                              Network.URI_NETWORK.format(uri),
                                              None, None, xml)
            return s

        return o
Пример #8
0
    def show_by_uri(self, uri, xml=False):
        '''
        Makes REST API call and retrieves network details based on UUID
        Parameters:
            uri: UUID of network
        Returns:
            Network details in JSON response payload
        '''

        (s, h) = common.service_json_request(self.__ipAddr, self.__port,
                                             "GET",
                                             Network.URI_NETWORK.format(uri),
                                             None)
        o = common.json_decode(s)
        if('inactive' in o):
            if(o['inactive']):
                return None

        if(xml):
            (s, h) = common.service_json_request(
                self.__ipAddr, self.__port,
                "GET", Network.URI_NETWORK.format(uri), None, None, xml)
            return s

        return o
 def storageport_delete_uri(self, uriport):
     '''
     Makes a REST API call to delete a storage port by its UUID
     '''
     common.service_json_request(self.__ipAddr, self.__port,
                                           "POST", Storageport.URI_RESOURCE_DEACTIVATE.format(Storageport.URI_STORAGEPORT.format(uriport)), None, None)
     return 0
Пример #10
0
    def project_show_by_uri(self, uri, xml=False):
        '''
        Makes REST API call and retrieves project derails based on UUID
        Parameters:
            uri: UUID of project
        Returns:
            Project details in JSON response payload
        '''
        if (xml):
            (s,
             h) = common.service_json_request(self.__ipAddr, self.__port,
                                              "GET",
                                              Project.URI_PROJECT.format(uri),
                                              None, None, xml)
            return s

        (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET",
                                             Project.URI_PROJECT.format(uri),
                                             None)
        o = common.json_decode(s)
        inactive = common.get_node_value(o, 'inactive')
        if (inactive == True):
            return None

        return o
Пример #11
0
    def assign(self, name, varray=None):
        '''
        Retrieves network details based on network name
        Parameters:
            name: name of the network.
            varray: varray to be assigned
        Returns:
            Network details in JSON response payload
        '''

        turi = self.query_by_name(name)
        nuri = None
        nlst = []
        if(varray):
            varray_obj = VirtualArray(self.__ipAddr, self.__port)
            for item in varray:
                nuri = varray_obj.varray_query(item)
                nlst.append(nuri)

        if(len(nlst) > 0):
            parms = {
                'varrays': nlst
            }
        else:
            parms = {
                'varrays': []
            }

        body = json.dumps(parms)
        common.service_json_request(self.__ipAddr, self.__port,
                                    "PUT",
                                    Network.URI_NETWORK.format(turi),
                                    body)
Пример #12
0
    def storageport_add(
        self, storage_device_name, serial_number, storage_device_type, port_name, port_id, transport_type
    ):

        storage_system = StorageSystem(self.__ipAddr, self.__port)
        storage_system_uri = None

        if serial_number:
            storage_system_uri = storage_system.query_by_serial_number_and_type(serial_number, storage_device_type)
        elif storage_device_name:
            storage_system_uri = storage_system.query_by_name_and_type(storage_device_name, storage_device_type)

        is_storageport_exist = True
        try:
            self.storageport_query(storage_system_uri, port_name)
        except SOSError as e:
            if e.err_code == SOSError.NOT_FOUND_ERR:
                is_storageport_exist = False
            else:
                raise e

        if is_storageport_exist:
            raise SOSError(SOSError.ENTRY_ALREADY_EXISTS_ERR, "storageport with name " + port_name + " already exists ")

        body = json.dumps({"name": port_name, "port_network_id": port_id, "transport_type": transport_type})

        common.service_json_request(
            self.__ipAddr, self.__port, "POST", Storageport.URI_STORAGEPORT_LIST.format(storage_system_uri), body
        )
Пример #13
0
    def show(self, name, project, tenant, xml=False):
        '''
        This function will take consistency group name and project name
        as input and It will display the consistency group with details.
        parameters:
           name : Name of the consistency group.
           project: Name of the project.
        return
            returns with Details of consistency group.
        '''
        uri = self.consistencygroup_query(name, project, tenant)
        (s, h) = common.service_json_request(
            self.__ipAddr, self.__port, "GET",
            self.URI_CONSISTENCY_GROUPS_INSTANCE.format(uri), None)
        o = common.json_decode(s)
        if (o['inactive']):
            return None

        if (xml is False):
            return o

        (s, h) = common.service_json_request(
            self.__ipAddr, self.__port, "GET",
            self.URI_CONSISTENCY_GROUPS_INSTANCE.format(uri), None, None, xml)

        if not s:
            return None
        return s
Пример #14
0
    def storageportgroup_add(self, storage_device_name, serial_number,
                             storage_device_type, portgroup_name,
                             storageports):

        storage_system = StorageSystem(self.__ipAddr, self.__port)
        storage_system_uri = None

        if (serial_number):
            storage_system_uri \
                = storage_system.query_by_serial_number_and_type(
                    serial_number, storage_device_type)
        elif (storage_device_name):
            storage_system_uri = storage_system.query_by_name_and_type(
                storage_device_name, storage_device_type)

        addports = []
        for portname in storageports:
            storage_port = Storageport(self.__ipAddr, self.__port)
            porturi = storage_port.storageport_query(storage_system_uri,
                                                     portname)
            addports.append(porturi)

        body = json.dumps({'name': portgroup_name, 'storage_ports': addports})

        common.service_json_request(
            self.__ipAddr, self.__port, "POST",
            Storageportgroup.URI_STORAGEPORTGROUP_LIST.format(
                storage_system_uri), body)
Пример #15
0
def cancel_scheduled_event(args):
    common.service_json_request(
        args.ip, args.port, "POST",
        "{}/{}/cancel".format(SCHEDULED_EVENT_BASE_URI, args.event_id),
        None, None)

    print("Scheduled Event is canceled successfully.")
Пример #16
0
    def storageportgroup_add(self, storage_device_name, serial_number,
                        storage_device_type, portgroup_name, storageports):

        storage_system = StorageSystem(self.__ipAddr, self.__port)
        storage_system_uri = None

        if(serial_number):
            storage_system_uri \
                = storage_system.query_by_serial_number_and_type(
                    serial_number, storage_device_type)
        elif(storage_device_name):
            storage_system_uri = storage_system.query_by_name_and_type(
                storage_device_name,
                storage_device_type)

        addports = []
        for portname in storageports:
            storage_port = Storageport(self.__ipAddr, self.__port)
            porturi = storage_port.storageport_query(storage_system_uri, portname)
            addports.append(porturi)
            
        body = json.dumps(
                          {'name': portgroup_name,
                           'storage_ports': addports
                           })

        common.service_json_request(self.__ipAddr, self.__port,
             "POST",
             Storageportgroup.URI_STORAGEPORTGROUP_LIST.format(storage_system_uri),
             body)
Пример #17
0
    def list_storageport_groups(self,
                                varrayName,
                                tenantName=None,
                                projectName=None,
                                exportGroupName=None):

        varrayUri = self.varray_query(varrayName)

        if (exportGroupName):
            from exportgroup import ExportGroup
            exportgroupObj = ExportGroup(self.__ipAddr, self.__port)
            exportgroup_uri = exportgroupObj.exportgroup_query(
                exportGroupName, projectName, tenantName, varrayuri)
            (s, h) = common.service_json_request(
                self.__ipAddr, self.__port, "GET",
                VirtualArray.URI_LIST_VIRTUALARRAY_STORAGE_PORT_GROUPS.format(
                    varrayUri) + "?export_group=" + exportgroup_uri, None)
        else:
            (s, h) = common.service_json_request(
                self.__ipAddr, self.__port, "GET",
                VirtualArray.URI_LIST_VIRTUALARRAY_STORAGE_PORT_GROUPS.format(
                    varrayUri), None)

        result = common.json_decode(s)
        return result['storage_port_group']
Пример #18
0
    def cluster_update(self, name, tenant, datacenter, vcenter, label):
        '''
        update cluster with datacenter, label
        Parameters:
            name      : Name of the cluster
            tenant    : name of tenant
            datacenter: Name of datacenter
            vcenter   : name of vcenter
            label     : new name to existing cluster
        Returns:
            result of the action.
        '''
        parms = {}
        # new name
        if(label):
            parms['name'] = label

        # datacenter
        if(datacenter):
            vdatacenterobj = VcenterDatacenter(self.__ipAddr, self.__port)
            data_uri = vdatacenterobj.vcenterdatacenter_query(
                datacenter, vcenter, tenant)
            parms['vcenter_data_center'] = data_uri

        # get the cluster uri
        cluster_uri = self.cluster_query(name, tenant)

        body = json.dumps(parms)
        common.service_json_request(self.__ipAddr, self.__port, "PUT",
                                    Cluster.URI_CLUSTER.format(cluster_uri),
                                    body)
        return
Пример #19
0
    def assign(self, name, varray=None):
        '''
        Retrieves network details based on network name
        Parameters:
            name: name of the network.
            varray: varray to be assigned
        Returns:
            Network details in JSON response payload
        '''

        turi = self.query_by_name(name)
        nuri = None
        nlst = []
        if (varray):
            varray_obj = VirtualArray(self.__ipAddr, self.__port)
            for item in varray:
                nuri = varray_obj.varray_query(item)
                nlst.append(nuri)

        if (len(nlst) > 0):
            parms = {'varrays': nlst}
        else:
            parms = {'varrays': []}

        body = json.dumps(parms)
        common.service_json_request(self.__ipAddr, self.__port, "PUT",
                                    Network.URI_NETWORK.format(turi), body)
Пример #20
0
    def get_catalog(self, uriPath, xml=False):

        if (uriPath is None):
            uriPath = ""
        elif (uriPath.startswith("/") is False):
            uriPath = "/" + uriPath

        command = singletonURIHelperInstance.getUri(self.COMPONENT_TYPE,
                                                    "catalog")
        port = self.__port
        if (len(uriPath) == 0):
            port = common.getenv('VIPR_UI_PORT')
        (s, h) = common.service_json_request(self.__ipAddr, port, "GET",
                                             command.format(uriPath), None)
        o = common.json_decode(s)
        inactive = common.get_node_value(o, 'inactive')

        if (inactive):
            return None
        if (xml):
            (s, h) = common.service_json_request(self.__ipAddr, port, "GET",
                                                 command.format(uriPath), None,
                                                 None, xml)
            return s
        else:
            return o
Пример #21
0
 def vdc_reconnect(self, name):
     uri = self.vdc_query(name)
     common.service_json_request(self.__ipAddr,
                         self.__port,
                         "POST",
                         VirtualDatacenter.URI_VDC_RECONNECT.format(uri),
                         None)
     return
Пример #22
0
 def storageportgroup_delete_uri(self, sduri, uriportgroup):
     '''
     Makes a REST API call to delete a storage port group by its UUID
     '''
     common.service_json_request(
         self.__ipAddr, self.__port, "POST",
         Storageportgroup.URI_STORAGEPORTGROUP_DELETE.format(
             sduri, uriportgroup), None)
     return 0
Пример #23
0
 def storageport_delete_uri(self, uriport):
     '''
     Makes a REST API call to delete a storage port by its UUID
     '''
     common.service_json_request(
         self.__ipAddr, self.__port, "POST",
         Storageport.URI_STORAGEPORT_DEACTIVATE.format((uriport)), None,
         None)
     return 0
Пример #24
0
 def storageportgroup_delete_uri(self, sduri, uriportgroup):
     '''
     Makes a REST API call to delete a storage port group by its UUID
     '''
     common.service_json_request(
         self.__ipAddr, self.__port,
         "POST",
         Storageportgroup.URI_STORAGEPORTGROUP_DELETE.format(sduri, uriportgroup),
         None)
     return 0
Пример #25
0
    def delete_by_uri(self, uri):
        '''
        Deletes a network based on network uri
        Parameters:
            uri: uri of network
        '''

        common.service_json_request(self.__ipAddr, self.__port, "POST",
                                    Network.URI_NETWORK_DEACTIVATE.format(uri),
                                    None)
        return
Пример #26
0
 def vdc_remove_role(self, name, role, subject_id, group):
     if (subject_id):
         objecttype = 'subject_id'
         objectname = subject_id
     else:
         objecttype = 'group'
         objectname = group
     parms = {"remove": [{"role": [role], objecttype: objectname}]}
     body = json.dumps(parms)
     common.service_json_request(self.__ipAddr, self.__port, "PUT",
                                 VirtualDatacenter.URI_VDC_GET_ROLE, body)
Пример #27
0
 def get_ipsec_status(self, xml=False):
     if (xml == False):
         (s, h) = common.service_json_request(self.__ipAddr, self.__port,
                                              "GET", IPsecManager.URI_IPSEC,
                                              None)
         return common.json_decode(s)
     else:
         (s, h) = common.service_json_request(self.__ipAddr, self.__port,
                                              "GET", IPsecManager.URI_IPSEC,
                                              None, None, xml)
         return s
Пример #28
0
    def show_execution_by_uri(self, uri, xml):
        command = singletonURIHelperInstance.getUri(self.COMPONENT_TYPE, "show-execution")
        if xml is True:
            (s, h) = common.service_json_request(
                self.__ipAddr, self.__port, "GET", command.format(uri), None, None, xml
            )
            return s
        else:
            (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", command.format(uri), None, None)
            o = common.json_decode(s)

            return o
Пример #29
0
    def delete_by_uri(self, uri):
        '''
        Deletes a network based on network uri
        Parameters:
            uri: uri of network
        '''

        common.service_json_request(self.__ipAddr, self.__port,
                                    "POST",
                                    Network.URI_NETWORK_DEACTIVATE.format(uri),
                                    None)
        return
Пример #30
0
    def deregister(self, name):
        '''
        register a network
        Parameters:
            name: name of network
        '''

        network_uri = self.query_by_name(name)

        common.service_json_request(
            self.__ipAddr, self.__port, "POST",
            Network.URI_NETWORK_DEREGISTER.format(network_uri), None)
    def cluster_search(self, name, project):
        

        if(project):
            (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", 
                                             Cluster.URI_CLUSTER_SEARCH_PROJECT.format(project), None)
        else:
            (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", 
                                             Cluster.URI_CLUSTER_SEARCH_NAME.format(name), None)
        o = common.json_decode(s)
        return o['resource']
    
        '''
Пример #32
0
 def get_ipsec_status(self, xml=False):
     if(xml == False):
         (s, h) = common.service_json_request(self.__ipAddr, self.__port,
                                              "GET",
                                              IPsecManager.URI_IPSEC,
                                              None)
         return common.json_decode(s)
     else:
         (s, h) = common.service_json_request(self.__ipAddr, self.__port,
                                              "GET",
                                              IPsecManager.URI_IPSEC,
                                              None, None, xml)
         return s
Пример #33
0
    def cluster_update(self,
                       name,
                       tenant,
                       datacenter,
                       vcenter,
                       label,
                       newdatacenter,
                       newvcenter,
                       autoexportsenabled,
                       updateExports=False):
        '''
        update cluster with datacenter, label
        Parameters:
            name      : Name of the cluster
            tenant    : name of tenant
            datacenter: Name of datacenter
            vcenter   : name of vcenter
            ndatacenter : name of new datacenter
            nvcenter : name of the new vcenter 
            label     : new name to existing cluster
        Returns:
            result of the action.
        '''
        parms = {}
        # new name
        if (label):
            parms['name'] = label

        if (autoexportsenabled is not None):
            parms['auto_export_enabled'] = autoexportsenabled

        # datacenter
        if (newdatacenter is not None):
            vdatacenterobj = VcenterDatacenter(self.__ipAddr, self.__port)
            data_uri = vdatacenterobj.vcenterdatacenter_query(
                newdatacenter, newvcenter, tenant)

            parms['vcenter_data_center'] = data_uri

        # get the cluster uri query to the right cluster ..

        cluster_uri = self.cluster_query(name, datacenter, vcenter, tenant)

        if (updateExports is not None):
            cluster_uri = cluster_uri + "?update-exports=" + updateExports

        body = json.dumps(parms)
        common.service_json_request(self.__ipAddr, self.__port, "PUT",
                                    Cluster.URI_CLUSTER.format(cluster_uri),
                                    body)
        return
Пример #34
0
    def deregister(self, name):
        '''
        register a network
        Parameters:
            name: name of network
        '''

        network_uri = self.query_by_name(name)

        common.service_json_request(
            self.__ipAddr, self.__port,
            "POST",
            Network.URI_NETWORK_DEREGISTER.format(network_uri),
            None)
Пример #35
0
    def show_fabrics_zones_by_uri(self, nsuri, fabricid, xml=False):

        if (xml == False):
            (s, h) = common.service_json_request(
                self.__ipAddr, self.__port, "GET",
                SanFabrics.URI_SAN_FABRICS_ZONE_LIST.format(nsuri, fabricid),
                None)
            return common.json_decode(s)
        else:
            (s, h) = common.service_json_request(
                self.__ipAddr, self.__port, "GET",
                SanFabrics.URI_SAN_FABRICS_ZONE_LIST.format(nsuri, fabricid),
                None, None, xml)
            return s
Пример #36
0
 def project_resource_show(self, fullname ,xml=False):
     project_uri = self.project_query(fullname)
     
     (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET",
                     Project.URI_PROJECT_RESOURCES.format(project_uri), None)
     o = common.json_decode(s)
  
     if xml:
         (s, h) = common.service_json_request(
             self.__ipAddr, self.__port, "GET",
             Project.URI_PROJECT_RESOURCES.format(project_uri),
             None, None, xml)
         return s
     else :
         return o
Пример #37
0
    def show_fabrics_zones_by_uri(self, nsuri, fabricid, xml=False):

        if(xml == False):
            (s, h) = common.service_json_request(self.__ipAddr, self.__port,
            "GET",
            SanFabrics.URI_SAN_FABRICS_ZONE_LIST.format(nsuri, fabricid),
            None)
            return common.json_decode(s)
        else:
            (s, h) = common.service_json_request(self.__ipAddr,
            self.__port,
            "GET",
            SanFabrics.URI_SAN_FABRICS_ZONE_LIST.format(nsuri, fabricid),
            None, None, xml)
            return s
Пример #38
0
    def show_san_fabrics_zone(self, name, fabricid, sanzone, xml=False):
        obj = Networksystem(self.__ipAddr, self.__port)
        nsuri = obj.networksystem_query(name)

        restapi = SanFabrics.URI_SAN_FABRICS_ZONE_LIST.format(nsuri, fabricid)
        restapi = restapi + "?zone-name=" + sanzone + "&exclude-members=false"
        if (xml == False):
            (s, h) = common.service_json_request(self.__ipAddr, self.__port,
                                                 "GET", restapi, None)
            return common.json_decode(s)
        else:
            (s, h) = common.service_json_request(self.__ipAddr, self.__port,
                                                 "GET", restapi, None, None,
                                                 xml)
            return s
 def full_update_acl(self, project_name):
     project_uri = self.project_query(project_name)
     
     (s, h) = common.service_json_request(self.__ipAddr, self.__port, "PUT",
                                          Project.URI_PROJECT_ACL.format(project_uri), None)
     o = common.json_decode(s)
     return o
Пример #40
0
    def datastore_query(self, type, name):
        '''
        Returns the UID of the datastore specified by the name
        '''
        if (common.is_uri(name)):
            return name

        (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET",
                                             URI_DATA_STORE_LIST, None)

        o = common.json_decode(s)

        pools = o['data_store']
        ids = []

        if (not o):
            return ()
        else:
            if (not isinstance(pools, list)):
                pools = [pools]
            for pool in pools:
                try:
                    pool_details = self.datastore_show_by_uri(
                        self.URI_DATA_STORE_LIST + '/' + type + '/' + uri)
                    if (pool_details['name'] == name):
                        return pool.get('id')
                except:
                    pass

        raise Exception('Bad Data Store name')
Пример #41
0
    def storagepool_register(self, systemuri, pooluri):
        '''
        Creates a storagepool with specified parameters
        Parameters:
            storagename:           name of the storage system
            protocol:        protocols supported by pool
            maxSnapshots:    maxSnapshots permitted on the storage pool
            consistency:    consistency details of storage pool
        returns:
            JSON payload of the created storagepool
        '''

        parms = dict()

        body = None

        if (parms):
            body = json.dumps(parms)

        (s, h) = common.service_json_request(
            self.__ipAddr, self.__port, "POST",
            StoragePool.URI_STORAGEPOOL_REGISTER.format(systemuri, pooluri),
            body)

        o = common.json_decode(s)
        return o
Пример #42
0
    def storagepool_update_by_uri(self, pooluri, varrays, maxresources,
                                  maxpoolutilization, maxthinpoolsubscription):
        '''
        Updates a storagepool
        '''
        parms = dict()
        body = None

        if (maxresources):
            parms['max_resources'] = maxresources

        if (maxpoolutilization):
            parms['max_pool_utilization_percentage'] = maxpoolutilization

        if (maxthinpoolsubscription):
            parms[
                'max_thin_pool_subscription_percentage'] = maxthinpoolsubscription

        if (varrays):
            parms['varray_assignment_changes'] = varrays
        body = json.dumps(parms)

        #myuri = '/vdc/storage-pools/'+ pooluri +'/matched-vpool'
        (s, h) = common.service_json_request(
            self.__ipAddr, self.__port, "PUT",
            StoragePool.URI_STORAGEPOOL_UPDATE.format(pooluri), body)

        o = common.json_decode(s)
        return o
Пример #43
0
    def storagepool_get_tiers_by_uri(self, pooluri):
        (s, h) = common.service_json_request(
            self.__ipAddr, self.__port, "GET",
            StoragePool.URI_STORAGEPOOL_TIERS.format(pooluri), None)

        o = common.json_decode(s)
        return o['storage_tier']
Пример #44
0
    def datastore_query(self, type, name):
        '''
        Returns the UID of the datastore specified by the name
        '''
        if (common.is_uri(name)):
            return name

        (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET",
                                             URI_DATA_STORE_LIST, None)

        o = common.json_decode(s)

        pools = o['data_store']
        ids = []

        if (not o):
            return ()
        else:
            if (not isinstance(pools, list)):
                pools = [pools]
            for pool in pools:
                try:
                    pool_details = self.datastore_show_by_uri(
                        self.URI_DATA_STORE_LIST +
                        '/' +
                        type +
                        '/' +
                        uri)
                    if (pool_details['name'] == name):
                        return pool.get('id')
                except:
                    pass

        raise Exception('Bad Data Store name')
Пример #45
0
    def storagepool_register(self, systemuri, pooluri):
        '''
        Creates a storagepool with specified parameters
        Parameters:
            storagename:           name of the storage system
            protocol:        protocols supported by pool
            maxSnapshots:    maxSnapshots permitted on the storage pool
            consistency:    consistency details of storage pool
        returns:
            JSON payload of the created storagepool
        '''

        parms = dict()

        body = None

        if (parms):
            body = json.dumps(parms)

        (s, h) = common.service_json_request(self.__ipAddr, self.__port,
                                             "POST",
                StoragePool.URI_STORAGEPOOL_REGISTER.format(systemuri,
                                                            pooluri),
                body)

        o = common.json_decode(s)
        return o
    def list(self, project, tenant):
        '''
        This function will give us the list of consistency group uris
        separated by comma.
        prameters:
            project: Name of the project path.
        return
            returns with list of consistency group ids separated by comma. 
        '''
        if(tenant == None):
            tenant = ""
        projobj = Project(self.__ipAddr, self.__port)
        fullproj = tenant+"/"+project
        projuri = projobj.project_query(fullproj)

        
        (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", 
                                             self.URI_CONSISTENCY_GROUPS_SEARCH.format(projuri), None)
        o = common.json_decode(s)
        if not o:
            return []
        
        congroups=[]
        resources = common.get_node_value(o, "resource")
        for resource in resources:
            congroups.append(resource["id"])
       
        return congroups
Пример #47
0
    def unassign(self, name, project=None):
        '''
        Vnasserver unassign
        Parameters:
            name: name of the vnasserver.
            project : varray to be assigned .
        Returns:
            
        
        '''
        vnasserverList = self.getvnasserverList(name)
        
        
        request =  {'vnas_server' : vnasserverList }

        if(project):
            proj_object = Project(self.__ipAddr, self.__port)
            pro_uri = proj_object.project_query(project)
                
                      
        body = json.dumps(request)
        (s, h) = common.service_json_request(self.__ipAddr, self.__port,
                                             "PUT",
                                             VnasServer.URI_VNASSERVER_UNASSIGN.format(pro_uri),
                                             body)
        
     
        if(s is not None and len(s) > 0):
            print s
            o = common.json_decode(s)
            return o
Пример #48
0
    def quotadirectory_updates(self, resourceUri, name, size, oplock, securitystyle, advlim, softlim, grace):
        qdUri = self.quotadirectory_query(
            resourceUri,
            name)
        parms = dict()

        if(size):
            size = common.to_bytes(size)
            parms["size"] = size
        if(oplock):
            parms["oplock"] = oplock
        if(securitystyle):
            parms["security_style"] = securitystyle
        if advlim:
            parms['notification_limit'] = advlim
        if softlim:
            parms['soft_limit'] = softlim
        if grace:
            parms['soft_grace'] = grace
            
        body = json.dumps(parms)

        # REST api call
        (s, h) = common.service_json_request(
            self.__ipAddr, self.__port,
            "POST",
            QuotaDirectory.URI_QUOTA_DIRECTORY_UPDATE.format(qdUri), body)

        o = common.json_decode(s)

        return
Пример #49
0
 def quotadirectory_list_uri(self, ouri):
     (s, h) = common.service_json_request(
         self.__ipAddr, self.__port,
         "GET",
         QuotaDirectory.URI_QUOTA_DIRECTORY.format(ouri), None)
     o = common.json_decode(s)
     return o['quota_dir']
Пример #50
0
    def create(self, ouri, name, size, oplock, securitystyle, sync,
               synctimeout, advlim, softlim, grace):
        parms = {
            'name': name,
        }
        if (size):
            size = common.to_bytes(size)
            parms["size"] = size
        if (oplock):
            parms["oplock"] = oplock
        if (securitystyle):
            parms["security_style"] = securitystyle
        if advlim:
            parms['notification_limit'] = advlim
        if softlim:
            parms['soft_limit'] = softlim
        if grace:
            parms['soft_grace'] = grace

        body = json.dumps(parms)

        # REST api call
        (s, h) = common.service_json_request(
            self.__ipAddr, self.__port, "POST",
            QuotaDirectory.URI_QUOTA_DIRECTORY.format(ouri), body)

        o = common.json_decode(s)

        if (sync):
            return (self.block_until_complete(o['resource']['id'], o["id"],
                                              synctimeout))
        else:
            return o
Пример #51
0
    def quotadirectory_updates(self, resourceUri, name, size, oplock,
                               securitystyle, advlim, softlim, grace):
        qdUri = self.quotadirectory_query(resourceUri, name)
        parms = dict()

        if (size):
            size = common.to_bytes(size)
            parms["size"] = size
        if (oplock):
            parms["oplock"] = oplock
        if (securitystyle):
            parms["security_style"] = securitystyle
        if advlim:
            parms['notification_limit'] = advlim
        if softlim:
            parms['soft_limit'] = softlim
        if grace:
            parms['soft_grace'] = grace

        body = json.dumps(parms)

        # REST api call
        (s, h) = common.service_json_request(
            self.__ipAddr, self.__port, "POST",
            QuotaDirectory.URI_QUOTA_DIRECTORY_UPDATE.format(qdUri), body)

        o = common.json_decode(s)

        return
Пример #52
0
    def storagepool_update_by_uri(self, pooluri, varrays,
                                  maxresources,
                                  maxpoolutilization,
                                  maxthinpoolsubscription):
        '''
        Updates a storagepool
        '''
        parms = dict()
        body = None

        if (maxresources):
            parms['max_resources'] = maxresources

        if (maxpoolutilization):
            parms['max_pool_utilization_percentage'] = maxpoolutilization

        if (maxthinpoolsubscription):
            parms[
            'max_thin_pool_subscription_percentage'] = maxthinpoolsubscription

        if(varrays):
            parms['varray_assignment_changes'] = varrays
        body = json.dumps(parms)

        #myuri = '/vdc/storage-pools/'+ pooluri +'/matched-vpool'
        (s, h) = common.service_json_request(self.__ipAddr, self.__port, "PUT",
                StoragePool.URI_STORAGEPOOL_UPDATE.format(pooluri), body)

        o = common.json_decode(s)
        return o
 def storagepool_delete_by_uri(self, uri):
     '''
     Deletes a storagepool identifited by the given URI
     '''
     (s, h) = common.service_json_request(self.__ipAddr, self.__port, "DELETE", 
                     StoragePool.URI_STORAGEPOOL.format(uri), None)
     return str(s) + " ++ " + str(h)
Пример #54
0
    def s3_key_delete(namespace, bucket, key, version, uid, secret):
        '''
        Makes a REST API call to delete a S3 key value pair
        Parameters:           
            key:  label of the key
            bucket:  label of the bucket
	    uid:	user id
	    secret:	secret
 	    namespace:	namespace
        Returns:
            JSON payload of key list
	'''
        _headers = dict()
        _headers['x-emc-namespace'] = namespace
        _headers['Date'] = formatdate()

        qparms = None
        if version:
            qparms = {'versionId': version}

        _headers = self.s3_hmac_base64_sig('DELETE', bucket, None, uid, secret,
                                           'application/json', _headers,
                                           qparms)

        uri = URI_S3_KEY_INSTANCE.format(bucket, key)

        if (qparms):
            for qk in qparms.iterkeys():
                if (qparms[qk] != None):
                    uri += '&' if ('?' in uri) else '?'
                    uri += qk + '=' + qparms[qk]

        (s, h) = common.service_json_request(self.__ipAddr, S3_PORT, "DELETE",
                                             uri, None, None, False, None,
                                             None, _headersi, 's3')
Пример #55
0
    def create(self, name, nwtype, varrays=None, endpoints=None):
        '''
        Makes REST API call to create network
        Parameters:
            name: name of network
            type: type of transport protocol. FC, IP or Ethernet
            varrays : List of varrays to be associated
            endpoints : List of endpoints to be added to network
        Returns:
            Created task details in JSON response payload
        '''

        networkId = self.query_by_name(name)
        if (networkId):
            raise SOSError(SOSError.ENTRY_ALREADY_EXISTS_ERR,
                           "Network with name " + name + " already exists")

        request = dict()
        request['name'] = name
        request['transport_type'] = nwtype

        if (varrays):
            request['varrays'] = self.getVarrayList(varrays)

        if (endpoints):
            request['endpoints'] = self.getEndPointList(endpoints)

        body = json.dumps(request)
        (s, h) = common.service_json_request(self.__ipAddr, self.__port,
                                             "POST", Network.URI_NETWORKS,
                                             body)
        o = common.json_decode(s)
        return o
Пример #56
0
    def storageport_update_uri(self, spuri, tzuri, varraysToAdd,
                               varrayToRemove, port_nw_id):

        # varray changes
        varray_obj = VirtualArray(self.__ipAddr, self.__port)
        addvarrayList = varray_obj.convertNamesToUris(varraysToAdd)
        removevarrayList = varray_obj.convertNamesToUris(varrayToRemove)

        parms = {
            'varray_assignment_changes': {
                'add': {
                    'varrays': addvarrayList
                },
                'remove': {
                    'varrays': removevarrayList
                }
            }
        }

        # Network to be associated
        if (tzuri):
            parms['network'] = tzuri

        if (port_nw_id):
            parms['port_network_id'] = port_nw_id

        body = json.dumps(parms)

        (s, h) = common.service_json_request(
            self.__ipAddr, self.__port, "PUT",
            Storageport.URI_STORAGEPORT_UPDATE.format(spuri), body)
        return common.json_decode(s)
Пример #57
0
 def delete(self, uri):
     command = singletonURIHelperInstance.getUri(self.COMPONENT_TYPE,
                                                 "show")
     (s, h) = common.service_json_request(self.__ipAddr,
                                          self.__port, "DELETE",
                                          command.format(uri), None)
     return s
 def storagepool_deregister_by_uri(self, deviceid , poolid):
     '''
     Deletes a storagepool identifited by the given URI
     '''
     (s, h) = common.service_json_request(self.__ipAddr, self.__port, "POST", 
                     StoragePool.URI_DEREGISTER.format(poolid), None)
     return str(s) + " ++ " + str(h)