コード例 #1
0
    def vcenterdatacenter_list(self, vcenter, tenantname):
        '''
        Returns all the vcenterdatacenters in a vdc
        Parameters:           
        Returns:
                JSON payload of vcenterdatacenter list
        '''

	from vcenter import VCenter
        obj = VCenter(self.__ipAddr, self.__port)
	uri = obj.vcenter_query(vcenter, tenantname)
            
        (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", 
                                             VcenterDatacenter.URI_VCENTER_DATACENTERS.format(uri), None)

        o = common.json_decode(s)
	
	return o['vcenter_data_center']
コード例 #2
0
    def vcenterdatacenter_list(self, vcenter, tenantname):
        '''
        Returns all the vcenterdatacenters in a vdc
        Parameters:
        Returns:
                JSON payload of vcenterdatacenter list
        '''

        from vcenter import VCenter
        obj = VCenter(self.__ipAddr, self.__port)
        uri = obj.vcenter_query(vcenter, tenantname)

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

        o = common.json_decode(s)

        return o['vcenter_data_center']
コード例 #3
0
    def vcenterdatacenter_create(self, label, vcenter, tenantname):
        '''
        creates a vcenterdatacenter
        parameters:
            label:  label of the vcenterdatacenter
        Returns:
            JSON payload response
        '''
        try:
            check = self.vcenterdatacenter_show(label, vcenter, tenantname)
            if (not check):
                raise SOSError(SOSError.NOT_FOUND_ERR,
                               "vcenterdatacenter " + label + ": not found")

        except SOSError as e:
            if (e.err_code == SOSError.NOT_FOUND_ERR):
                from vcenter import VCenter
                obj = VCenter(self.__ipAddr, self.__port)

                vcenteruri = obj.vcenter_query(vcenter, tenantname)

                var = dict()
                params = dict()
                params['name'] = label

                body = json.dumps(params)
                (s, h) = common.service_json_request(
                    self.__ipAddr, self.__port, "POST",
                    VcenterDatacenter.URI_VCENTER_DATACENTERS.format(
                        vcenteruri), body)
                o = common.json_decode(s)
                return o
            else:
                raise e

        if (check):
            raise SOSError(
                SOSError.ENTRY_ALREADY_EXISTS_ERR,
                "vcenterdatacenter with name " + label + " already exists")
コード例 #4
0
    def vcenterdatacenter_create(self, label, vcenter, tenantname):
        '''
        creates a vcenterdatacenter
        parameters:
            label:  label of the vcenterdatacenter
        Returns:
            JSON payload response
        '''
        try:
            check = self.vcenterdatacenter_show(label, vcenter, tenantname)
            if(not check):
                raise SOSError(SOSError.NOT_FOUND_ERR,
                               "vcenterdatacenter " + label + ": not found")

        except SOSError as e:
            if(e.err_code == SOSError.NOT_FOUND_ERR):
                from vcenter import VCenter
                obj = VCenter(self.__ipAddr, self.__port)

                vcenteruri = obj.vcenter_query(vcenter, tenantname)

                var = dict()
                params = dict()
                params['name'] = label

                body = json.dumps(params)
                (s, h) = common.service_json_request(
                    self.__ipAddr, self.__port, "PUT",
                    VcenterDatacenter.URI_VCENTER_DATACENTERS.format(
                        vcenteruri), body)
                o = common.json_decode(s)
                return o
            else:
                raise e

        if(check):
            raise SOSError(SOSError.ENTRY_ALREADY_EXISTS_ERR,
                           "vcenterdatacenter with name " + label +
                           " already exists")