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']
Example #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']
Example #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")
    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")
Example #5
0
    def tenant_get_vcenters(self, label, xml=False):
        """
        Makes a REST API call to retrieve details of a tenant based on its UUID
        """
        if label:
            id = self.tenant_query(label)
        else:
            id = self.tenant_getid()

        (s, h) = common.service_json_request(
            self.__ipAddr, self.__port, "GET", Tenant.URI_TENANT_VCENTERS.format(id), None, None, xml
        )

        o = common.json_decode(s)

        from vcenter import VCenter

        obj = VCenter(self.__ipAddr, self.__port)

        dtlslst = obj.vcenter_get_details_list(o["vcenter"])

        return dtlslst
Example #6
0
 def __init__ (self, id, fchosts, vcenter):
     Storage.__init__(self, id, fchosts)
     self.vcenter_id = ''
     if vcenter:
         self.vcenter = VCenter(vcenter)
         self.vcenter_id = vcenter