예제 #1
0
    def __init__(self, plugins=None):
        """User preference for each service.

        :param plugins: List of entry point namespaces to load.

        Create a new :class:`~openstack.profile.Profile`
        object with no preferences defined, but knowledge of the services.
        Services are identified by their service type, e.g.: 'identity',
        'compute', etc.
        """
        self._services = {}

        self._add_service(alarm_service.AlarmService(version="v2"))
        self._add_service(bare_metal_service.BareMetalService(version="v1"))
        self._add_service(block_store_service.BlockStoreService(version="v2"))
        self._add_service(cluster_service.ClusterService(version="v1"))
        self._add_service(compute_service.ComputeService(version="v2"))
        self._add_service(database_service.DatabaseService(version="v1"))
        self._add_service(identity_service.IdentityService(version="v3"))
        self._add_service(image_service.ImageService(version="v2"))
        self._add_service(key_manager_service.KeyManagerService(version="v1"))
        self._add_service(message_service.MessageService(version="v1"))
        self._add_service(network_service.NetworkService(version="v2"))
        self._add_service(
            object_store_service.ObjectStoreService(version="v1"))
        self._add_service(
            orchestration_service.OrchestrationService(version="v1"))
        self._add_service(telemetry_service.TelemetryService(version="v2"))

        if plugins:
            for plugin in plugins:
                self._load_plugin(plugin)
        self.service_keys = sorted(self._services.keys())
예제 #2
0
 def test_service(self):
     sot = alarm_service.AlarmService()
     self.assertEqual('alarming', sot.service_type)
     self.assertEqual('public', sot.interface)
     self.assertIsNone(sot.region)
     self.assertIsNone(sot.service_name)
     self.assertEqual(1, len(sot.valid_versions))
     self.assertEqual('v2', sot.valid_versions[0].module)
     self.assertEqual('v2', sot.valid_versions[0].path)
예제 #3
0
    def __init__(self, plugins=None):
        """User preference for each service.

        :param plugins: List of entry point namespaces to load.

        Create a new :class:`~openstack.profile.Profile`
        object with no preferences defined, but knowledge of the services.
        Services are identified by their service type, e.g.: 'identity',
        'compute', etc.
        """
        self._services = {}

        self._add_service(anti_ddos_service.AntiDDosService(version="v1"))
        self._add_service(alarm_service.AlarmService(version="v2"))
        self._add_service(bare_metal_service.BareMetalService(version="v1"))
        self._add_service(block_store_service.BlockStoreService(version="v2"))
        self._add_service(cluster_service.ClusterService(version="v1"))
        self._add_service(compute_service.ComputeService(version="v2"))
        self._add_service(cts_service.CTSService(version="v1"))
        self._add_service(database_service.DatabaseService(version="v1"))
        self._add_service(dms_service.DMSService(version="v1"))
        self._add_service(identity_service.IdentityService(version="v3"))
        self._add_service(image_service.ImageService(version="v2"))
        self._add_service(key_manager_service.KeyManagerService(version="v1"))
        self._add_service(kms_service.KMSService(version="v1"))
        self._add_service(lb_service.LoadBalancerService(version="v1"))
        self._add_service(maas_service.MaaSService(version="v1"))
        self._add_service(message_service.MessageService(version="v1"))
        self._add_service(network_service.NetworkService(version="v2"))
        self._add_service(
            object_store_service.ObjectStoreService(version="v1"))
        self._add_service(
            orchestration_service.OrchestrationService(version="v1"))
        self._add_service(rds_service.RDSService(version="v1"))
        self._add_service(rds_os_service.RDSService(version="v1"))
        self._add_service(smn_service.SMNService(version="v2"))
        self._add_service(telemetry_service.TelemetryService(version="v2"))
        self._add_service(workflow_service.WorkflowService(version="v2"))
        # QianBiao.NG HuaWei Services
        self._add_service(dns_service.DNSService(version="v2"))
        self._add_service(cloud_eye_service.CloudEyeService(version="v1"))
        ass = auto_scaling_service.AutoScalingService(version="v1")
        self._add_service(ass)
        vbs_v2 = volume_backup_service.VolumeBackupService(version="v2")
        self._add_service(vbs_v2)
        self._add_service(map_reduce_service.MapReduceService(version="v1"))

        if plugins:
            for plugin in plugins:
                self._load_plugin(plugin)
        self.service_keys = sorted(self._services.keys())
예제 #4
0
class AlarmChange(resource.Resource):
    """.. caution:: This API is a work in progress and is subject to change."""
    id_attribute = 'event_id'
    resource_key = 'alarm_change'
    base_path = '/alarms/%(alarm_id)s/history'
    service = alarm_service.AlarmService()

    # Supported Operations
    allow_list = True

    # Properties
    #: The ID of the alarm
    alarm_id = resource.prop('alarm_id')
    #: Data describing the change
    detail = resource.prop('detail')
    #: The ID of the change event
    event_id = resource.prop('event_id')
    #: The project ID on behalf of which the change is being made
    on_behalf_of_id = resource.prop('on_behalf_of')
    #: The project ID of the initiating identity
    project_id = resource.prop('project_id')
    #: The time/date of the alarm change.
    #: *Type: ISO 8601 formatted string*
    triggered_at = resource.prop('timestamp')
    #: The type of change
    type = resource.prop('type')
    #: The user ID of the initiating identity
    user_id = resource.prop('user_id')

    @classmethod
    def list(cls, session, limit=None, marker=None, path_args=None,
             paginated=False, **params):
        url = cls._get_url(path_args)
        resp = session.get(url, endpoint_filter=cls.service, params=params)
        for item in resp.json():
            yield cls.existing(**item)
예제 #5
0
class Alarm(resource.Resource):
    """.. caution:: This API is a work in progress and is subject to change."""
    id_attribute = 'alarm_id'
    base_path = '/alarms'
    service = alarm_service.AlarmService()

    # Supported Operations
    allow_create = True
    allow_retrieve = True
    allow_update = True
    allow_delete = True
    allow_list = True

    # Properties
    #: The actions to do when alarm state changes to alarm
    alarm_actions = resource.prop('alarm_actions')
    #: The ID of the alarm
    alarm_id = resource.prop('alarm_id')
    # TODO(briancurtin): undocumented
    combination_rule = resource.prop('combination_rule')
    #: The description of the alarm
    description = resource.prop('description')
    #: ``True`` if this alarm is enabled. *Type: bool*
    is_enabled = resource.prop('enabled', type=bool)
    #: The actions to do when alarm state changes to insufficient data
    insufficient_data_actions = resource.prop('insufficient_data_actions')
    #: The actions should be re-triggered on each evaluation cycle.
    #: *Type: bool*
    is_repeat_actions = resource.prop('repeat_actions', type=bool)
    #: The name for the alarm
    name = resource.prop('name')
    #: The actions to do when alarm state change to ok
    ok_actions = resource.prop('ok_actions')
    #: The ID of the project that owns the alarm
    project_id = resource.prop('project_id')
    #: The severity of the alarm
    severity = resource.prop('severity')
    #: The state off the alarm
    state = resource.prop('state')
    #: The timestamp of the last alarm state change.
    #: *Type: ISO 8601 formatted string*
    state_changed_at = resource.prop('state_timestamp')
    # TODO(briancurtin): undocumented
    threshold_rule = resource.prop('threshold_rule', type=dict)
    #: Describe time constraints for the alarm
    time_constraints = resource.prop('time_constraints')
    #: Explicit type specifier to select which rule to follow
    type = resource.prop('type')
    #: The timestamp of the last alarm definition update.
    #: *Type: ISO 8601 formatted string*
    updated_at = resource.prop('timestamp')
    #: The ID of the user who created the alarm
    user_id = resource.prop('user_id')

    def change_state(self, session, next_state):
        """Set the state of an alarm.

        :param next_state: The valid values can be one of: ``ok``, ``alarm``,
                           ``insufficient data``.
        """
        url = utils.urljoin(self.base_path, self.id, 'state')
        resp = session.put(url, endpoint_filter=self.service, json=next_state)
        return resp.json()

    def check_state(self, session):
        """Retrieve the current state of an alarm from the service.

        The properties of the alarm are not modified.
        """
        url = utils.urljoin(self.base_path, self.id, 'state')
        resp = session.get(url, endpoint_filter=self.service)
        resp = resp.json()
        current_state = resp.replace('\"', '')
        return current_state