Ejemplo n.º 1
0
    def _get_floatingip_collection(self, message):
        floatingip = message['payload']['floatingip']
        service = const.SERVICE_NETWORK
        region_id = cfg.CONF.region_name

        product_name = generate_product_name(message)
        if product_name != const.PRODUCT_FLOATINGIP:
            product = self.gclient.get_product(
                product_name, service, region_id)
            if not product:
                product_name = const.PRODUCT_FLOATINGIP

        resource_id = floatingip['id']
        resource_name = floatingip['uos:name']
        resource_type = const.RESOURCE_FLOATINGIP
        resource_volume = pricing.rate_limit_to_unit(
            floatingip['rate_limit'])
        user_id = None
        project_id = floatingip['tenant_id']

        return Collection(product_name=product_name,
                          service=service,
                          region_id=region_id,
                          resource_id=resource_id,
                          resource_name=resource_name,
                          resource_type=resource_type,
                          resource_volume=resource_volume,
                          user_id=user_id, project_id=project_id)
Ejemplo n.º 2
0
    def get_collection(self, message):
        """Get collection from message
        """
        if message['payload']['volume_type']:
            from gringotts.services import cinder
            volume_type = cinder.volume_type_get(message['payload']['volume_type'],
                                                 region_name=cfg.CONF.region_name)
            if volume_type and volume_type == 'sata':
                product_name = const.PRODUCT_SATA_VOLUME_SIZE
            else:
                product_name = const.PRODUCT_VOLUME_SIZE
        else:
            product_name = const.PRODUCT_VOLUME_SIZE
        service = const.SERVICE_BLOCKSTORAGE
        region_id = cfg.CONF.region_name
        resource_id = message['payload']['volume_id']
        resource_name = message['payload']['display_name']
        resource_type = const.RESOURCE_VOLUME
        resource_volume = message['payload']['size']
        user_id = message['payload']['user_id']
        project_id = message['payload']['tenant_id']

        return Collection(product_name=product_name,
                          service=service,
                          region_id=region_id,
                          resource_id=resource_id,
                          resource_name=resource_name,
                          resource_type=resource_type,
                          resource_volume=resource_volume,
                          user_id=user_id,
                          project_id=project_id)
Ejemplo n.º 3
0
    def get_collection(self, message):
        """Get collection from message
        """
        image_label = message['payload']['image_meta'].get(
            'image_label') or 'default'

        product_name = 'license:%s' % image_label
        service = const.SERVICE_COMPUTE
        region_id = cfg.CONF.region_name
        resource_id = message['payload']['instance_id']
        resource_name = message['payload']['display_name']
        resource_type = const.RESOURCE_INSTANCE
        resource_volume = 1
        user_id = message['payload']['user_id']
        project_id = message['payload']['tenant_id']

        return Collection(product_name=product_name,
                          service=service,
                          region_id=region_id,
                          resource_id=resource_id,
                          resource_name=resource_name,
                          resource_type=resource_type,
                          resource_volume=resource_volume,
                          user_id=user_id,
                          project_id=project_id)
Ejemplo n.º 4
0
    def get_collection(self, message):
        """Get collection from message
        """
        instance_type = message['payload']['instance_type']

        product_name = '%s:%s' % (const.PRODUCT_INSTANCE_TYPE_PREFIX,
                                  instance_type)
        service = const.SERVICE_COMPUTE
        region_id = cfg.CONF.region_name
        resource_id = message['payload']['instance_id']
        resource_name = message['payload']['display_name']
        resource_type = const.RESOURCE_INSTANCE
        resource_volume = 1
        user_id = message['payload']['user_id']
        project_id = message['payload']['tenant_id']

        return Collection(product_name=product_name,
                          service=service,
                          region_id=region_id,
                          resource_id=resource_id,
                          resource_name=resource_name,
                          resource_type=resource_type,
                          resource_volume=resource_volume,
                          user_id=user_id,
                          project_id=project_id)
Ejemplo n.º 5
0
    def get_collection(self, message):
        """Get collection from message
        """
        product_name = const.PRODUCT_SHARE
        service = const.SERVICE_SHARE
        region_id = cfg.CONF.region_name
        resource_id = message['payload']['share_id']
        resource_name = message['payload']['display_name']
        resource_type = const.RESOURCE_SHARE
        resource_volume = message['payload']['size']
        user_id = message['payload']['user_id']
        project_id = message['payload']['tenant_id']

        return Collection(product_name=product_name,
                          service=service,
                          region_id=region_id,
                          resource_id=resource_id,
                          resource_name=resource_name,
                          resource_type=resource_type,
                          resource_volume=resource_volume,
                          user_id=user_id,
                          project_id=project_id)
Ejemplo n.º 6
0
    def get_collection(self, message):
        """Get collection from message
        """
        product_name = const.PRODUCT_ROUTER
        service = const.SERVICE_NETWORK
        region_id = cfg.CONF.region_name
        resource_id = message['payload']['router']['id']
        resource_name = message['payload']['router']['name']
        resource_type = const.RESOURCE_ROUTER
        resource_volume = 1
        user_id = None
        project_id = message['payload']['router']['tenant_id']

        return Collection(product_name=product_name,
                          service=service,
                          region_id=region_id,
                          resource_id=resource_id,
                          resource_name=resource_name,
                          resource_type=resource_type,
                          resource_volume=resource_volume,
                          user_id=user_id,
                          project_id=project_id)
Ejemplo n.º 7
0
    def get_collection(self, message):
        """Get collection from message
        """
        product_name = const.PRODUCT_ALARM
        service = const.SERVICE_MONITOR
        region_id = cfg.CONF.region_name
        resource_id = message['payload']['alarm_id']
        resource_name = message['payload']['detail']['name']
        resource_type = const.RESOURCE_ALARM
        resource_volume = 1
        user_id = message['payload']['user_id']
        project_id = message['payload']['project_id']

        return Collection(product_name=product_name,
                          service=service,
                          region_id=region_id,
                          resource_id=resource_id,
                          resource_name=resource_name,
                          resource_type=resource_type,
                          resource_volume=resource_volume,
                          user_id=user_id,
                          project_id=project_id)
Ejemplo n.º 8
0
    def _get_floatingipset_collection(self, message):
        floatingipset = message['payload']['floatingipset']

        product_name = generate_product_name(message)
        service = const.SERVICE_NETWORK
        region_id = cfg.CONF.region_name
        resource_id = floatingipset['id']
        resource_name = floatingipset['uos:name']
        resource_type = const.RESOURCE_FLOATINGIPSET
        resource_volume = pricing.rate_limit_to_unit(
            floatingipset['rate_limit'])
        user_id = None
        project_id = floatingipset['tenant_id']

        return Collection(product_name=product_name,
                          service=service,
                          region_id=region_id,
                          resource_id=resource_id,
                          resource_name=resource_name,
                          resource_type=resource_type,
                          resource_volume=resource_volume,
                          user_id=user_id, project_id=project_id)
Ejemplo n.º 9
0
    def get_collection(self, message):
        """Get collection from message
        """
        product_name = const.PRODUCT_VOLUME_SIZE
        service = const.SERVICE_BLOCKSTORAGE
        region_id = cfg.CONF.region_name
        resource_id = message['payload']['instance_id']
        resource_name = message['payload']['display_name']
        resource_type = const.RESOURCE_INSTANCE
        resource_volume = message['payload']['disk_gb']
        user_id = message['payload']['user_id']
        project_id = message['payload']['tenant_id']

        return Collection(product_name=product_name,
                          service=service,
                          region_id=region_id,
                          resource_id=resource_id,
                          resource_name=resource_name,
                          resource_type=resource_type,
                          resource_volume=resource_volume,
                          user_id=user_id,
                          project_id=project_id)
Ejemplo n.º 10
0
    def get_collection(self, message):
        """Get collection from message
        """
        product_name = const.PRODUCT_SNAPSHOT_SIZE
        service = const.SERVICE_BLOCKSTORAGE
        region_id = cfg.CONF.region_name
        resource_id = message['payload']['id']
        resource_name = message['payload']['name']
        resource_type = const.RESOURCE_IMAGE
        resource_volume = message['payload']['size'] / (1024 * 1024 * 1024)
        user_id = None
        project_id = message['payload']['owner']

        return Collection(product_name=product_name,
                          service=service,
                          region_id=region_id,
                          resource_id=resource_id,
                          resource_name=resource_name,
                          resource_type=resource_type,
                          resource_volume=resource_volume,
                          user_id=user_id,
                          project_id=project_id)