How to use the common.json_decode function in common

To help you get started, we’ve selected a few common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CoprHD / coprhd-controller / cli / src / network.py View on Github external
def query_by_name(self, nwName):
        (s, h) = common.service_json_request(
            self.__ipAddr, self.__port, "GET",
            self.URI_NETWORK_SEARCH.format(nwName), None)

        o = common.json_decode(s)
        if not o:
            return None

        resources = common.get_node_value(o, "resource")
        if(len(resources) > 0):
            component_uri = resources[0]['id']
            nw_details = self.show_by_uri(component_uri, False)
            if(nw_details is not None):
                return component_uri

        return None
github CoprHD / coprhd-controller / cli / src / vcenter.py View on Github external
def vcenter_discover(self, label, tenantname):
        '''
        Makes a REST API call to delete a vcenter by its UUID
        '''
        uri = self.vcenter_query(label, tenantname)

        (s, h) = common.service_json_request(
            self.__ipAddr, self.__port, "POST",
            self.URI_VCENTER_DISCOVER.format(uri),
            None)

        o = common.json_decode(s)
        return o
github CoprHD / coprhd-controller / cli / src / event.py View on Github external
def event_list(self, tenant):
        uri = Tenant(self.__ipAddr, self.__port).tenant_query(tenant)

        (s, h) = common.service_json_request(
            self.__ipAddr, self.__port, "GET",
            Event.URI_EVENTS.format(uri), None)
        o = common.json_decode(s)
        return o['event']
github emcvipr / controller-openstack-cinder / cinder / volume / drivers / emc / vipr / cli / volume.py View on Github external
def mirror_protection_pause(self, volume, mirrorvol):
	'''
        pause the block mirror volume, which is attached to name volume
        Parameters:
            volume   : Name of the volume
			mirrorvol: Name of the mirror volume
        Returns:
            result of the action.
        '''
        vol_uri = self.volume_query(volume)
	mir_vol = self.mirror_volume_query(volume, mirrorvol)
        (s, h) = common.service_json_request(self.__ipAddr, self.__port,
                                             "POST",
                                             Volume.URI_VOLUME_PROTECTION_MIRROR_INSTANCE_PAUSE.format(vol_uri, mir_vol),
                                             None)			
        return common.json_decode(s)	
github CoprHD / coprhd-controller / cli / src / fileshare.py View on Github external
alldir : list the acls for all the directories
            subdir : list the acl's of a particular subdirectory
            
        '''
        uri_nfs_qp = Fileshare.URI_NFS_ACL
        if(alldir == True):
            uri_nfs_qp = Fileshare.URI_NFS_ACL + '?' + "allDirs=true"
        if(subdir is not None):
            uri_nfs_qp = Fileshare.URI_NFS_ACL + '?' + "subDir=" + subdir
        fileshare_uri = self.fileshare_query(name)

        (s, h) = common.service_json_request(
            self.__ipAddr, self.__port, "GET",
            uri_nfs_qp.format(fileshare_uri),
            None)
        o = common.json_decode(s)
        return o
github emcvipr / controller-openstack-cinder / cinder / volume / drivers / emc / vipr / lib / volume.py View on Github external
def protectionset_getresources(self, volume):
	'''
         This function is to do different action on protection set for given volume
        Parameters:
            volume: Name of the volume
        Returns:
            result of the action.
        '''
        vol_uri = self.volume_query(volume)
	vol = self.show_by_uri(vol_uri)
        if(vol and 'protection_set' in vol):		
	    (s, h) = common.service_json_request(self.__ipAddr, self.__port,
                                             "GET",
                                             Volume.URI_VOLUME_PROTECTIONSET_RESOURCES.format(vol['protection_set']['id']),
                                             None)
            if( not common.json_decode(s)):
                return None
            return common.json_decode(s)
	else:
            raise SOSError(SOSError.SOS_FAILURE_ERR, "Volume does not have protection set Info")
github CoprHD / coprhd-controller / cli / src / hostipinterfaces.py View on Github external
def show_by_uri(self, uri, xml=False):
        '''
        Makes a REST API call to retrieve details of a Host based on its UUID
        '''
        (s, h) = common.service_json_request(
            self.__ipAddr, self.__port, "GET",
            HostIPInterface.URI_IPINTERFACE_DETAILS.format(uri),
            None, 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, self.__port, "GET",
                HostIPInterface.URI_IPINTERFACE_DETAILS.format(uri),
                None, None, xml)
            return s
        else:
            return o
github CoprHD / coprhd-controller / cli / src / keypool.py View on Github external
'GET',
            None,
            None,
            uid,
            secret,
            'application/json',
            _headers,
            None)

        (s, h) = common.service_json_request(self.__ipAddr, S3_PORT, "GET",
                                             self.URI_S3_SERVICE_BASE, None,
                                             None, False,
                                             'application/json',
                                             None, _headers)

        o = common.json_decode(s)

        return o
github emcvipr / controller-openstack-cinder / cinder / volume / drivers / emc / vipr / cli / storageport.py View on Github external
def storageport_update_uri(self, spuri, tzuri):
        
        parms = {}
        if (tzuri):
            parms['network'] = tzuri
        else:
            parms['auto_network'] = 'true'
        
        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)
github CoprHD / coprhd-controller / cli / src / vcenter.py View on Github external
def vcenter_show(self, label, tenantname, xml=False):
        '''
        Makes a REST API call to retrieve details of a vcenter
        based on its UUID
        '''

        uri = self.vcenter_query(label, tenantname)

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

        if(not xml):
            o = common.json_decode(s)

            if('inactive' in o):
                if(o['inactive']):
                    return None
        else:
            return s

        return o