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

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

        Create a new :class:`~ecl.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(compute_service.ComputeService(version="v2"))
        self._add_service(
            connectivity_service.ConnectivityService(version="v1"))
        self._add_service(identity_service.IdentityService(version="v3"))
        self._add_service(image_service.ImageService(version="v2"))
        self._add_service(network_service.NetworkService(version="v2"))
        self._add_service(sss_service.SssService(version="v1"))
        self._add_service(
            orchestration_service.OrchestrationService(version="v1"))
        self._add_service(
            provider_connectivity_service.ProviderConnectivityService(
                version="v2"))
        self._add_service(telemetry_service.TelemetryService(version="v2"))
        self._add_service(block_store_service.BlockStoreService(version="v2"))
        self._add_service(storage_service.StorageService(version="v1"))
        self._add_service(
            security_order_service.SecurityOrderService(version="v2"))
        self._add_service(
            security_portal_service.SecurityPortalService(version="v2"))
        ## This section will be deleted if MSS v1 API is not available
        self._add_service(
            security_order_service_v1.SecurityOrderService(version="v1"))
        self._add_service(
            security_portal_service_v1.SecurityPortalService(version="v1"))
        ## end of the section
        self._add_service(rca_service.RcaService(version="v1"))
        self._add_service(baremetal_service.BaremetalService(version="v2"))
        self._add_service(
            dedicated_hypervisor_service.DedicatedHypervisorService(
                version="v1"))
        self._add_service(dns_service.DnsService(version="v2"))
        self._add_service(
            virtual_network_appliance_service.VirtualNetworkApplianceService(
                version="v1"))
        self._add_service(mvna_service.MVNAService(version="v1"))

        # NOTE: The Metric service is not added here as it currently
        # only retrieves the /capabilities API.

        if plugins:
            for plugin in plugins:
                self._load_plugin(plugin)
        self.service_keys = sorted(self._services.keys())
Exemple #2
0
class WAF(resource2.Resource):
    resource_key = None
    resources_key = None
    base_path = '/API/SoEntryFGWAF'
    service = security_order_service.SecurityOrderService()

    # Capabilities
    allow_create = True
    allow_get = True
    allow_delete = True
    allow_list = True
    allow_update = True

    # Properties
    #: Tenant ID of the owner (UUID).
    tenant_id = resource2.Body('tenant_id')
    #: List of following objects.
    #: operatingmode: Set "WAF" to this value.
    #: licensekind: Set "02", "04" or "08" as WAF plan.
    #: azgroup: Availability Zone.
    gt_host = resource2.Body('gt_host')
    #: A: Create Single Constitution Device.
    #: M: Update Single Constitution Device.
    #: D: Delete Single Constitution Device.
    sokind = resource2.Body('sokind')
    #: Messages are displayed in Japanese or English depending on this value.
    #: ja: Japanese, en: English. Default value is "en".
    locale = resource2.Body('locale')
    #: This value indicates normal or abnormal. 1:normal, 2:abnormal.
    code = resource2.Body('code', alternate_id=True)
    #: This message is shown when error has occurred.
    message = resource2.Body('message')
    #: Identification ID of Service Order.
    soid = resource2.Body('soId')
    #: This value indicates normal or abnormal. 1:normal, 2:abnormal.
    status = resource2.Body('status')
    #: Number of devices.
    records = resource2.Body('records')
    #: Device list.
    rows = resource2.Body('rows')
    #: List of device objects.
    devices = resource2.Body('devices')
    #: Percentage of Service Order Progress Status.
    progress_rate = resource2.Body('progressRate')
    #: List of device objects.
    devices = resource2.Body('devices')

    def get_order_status(self, session, soid, locale=None):
        tenant_id = session.get_project_id()
        uri = '/API/ScreenEventFGWAFOrderProgressRate?tenant_id=%s&soid=%s' \
              % (tenant_id, soid)
        if locale is not None:
            uri += '&locale=%s' % locale
        headers = {'Content-Type': 'application/json'}
        resp = session.get(uri, endpoint_filter=self.service, headers=headers)
        self._translate_response(resp, has_body=True)
        return self

    def update(self, session, **body):
        uri = self.base_path
        resp = session.post(uri, endpoint_filter=self.service, json=body)
        self._translate_response(resp, has_body=True)
        return self

    def delete(self, session, body, locale=None):
        uri = self.base_path
        resp = session.post(uri, endpoint_filter=self.service, json=body)
        self._translate_response(resp, has_body=True)
        return self

    def list(self, session, locale=None):
        tenant_id = session.get_project_id()
        uri = '/API/ScreenEventFGWAFDeviceGet?tenant_id=%s' % tenant_id
        if locale is not None:
            uri += '&locale=%s' % locale
        headers = {'Content-Type': 'application/json'}
        resp = session.get(uri, endpoint_filter=self.service, headers=headers)
        body = resp.json()
        devices = []
        for row in body['rows']:
            device = {
                'internal_use': row['cell'][0],
                'rows': row['cell'][1],
                'hostname': row['cell'][2],
                'menu': row['cell'][3],
                'plan': row['cell'][4],
                'availability_zone': row['cell'][5],
                'zone_name': row['cell'][6],
            }
            devices.append(device)
        body.update({'devices': devices})
        self._translate_list_response(resp, body, has_body=True)
        return self

    def _translate_list_response(self, response, body, has_body=True):
        if has_body:
            if self.resource_key and self.resource_key in body:
                body = body[self.resource_key]

            body = self._filter_component(body, self._body_mapping())
            self._body.attributes.update(body)
            self._body.clean()

        headers = self._filter_component(response.headers,
                                         self._header_mapping())
        self._header.attributes.update(headers)
        self._header.clean()
class HostBasedSecurity(resource2.Resource):
    resource_key = None
    resources_key = None
    base_path = '/API/SoEntryHBS'
    service = security_order_service.SecurityOrderService()

    # Capabilities
    allow_create = True
    allow_get = True
    allow_delete = True
    allow_list = True
    allow_update = True

    #: Tenant ID of the owner (UUID).
    tenant_id = resource2.Body('tenant_id')
    #: N: Order New Host-based Security.
    #: M1: Change menu of Host-based Security.
    #: M2: Change quantity of Host-based Security.
    #: C: Cancel Host-based Security.
    sokind = resource2.Body('sokind')
    #: Requested menu. Set "Managed Anti-Virus", "Managed Virtual Patch"
    #: or "Managed Host-based Security Package" to this field.
    service_order_service = resource2.Body('service_order_service')
    #: Set maximum quantity of Agenet usage.
    max_agent_value = resource2.Body('max_agent_value')
    #: Contactable mail address.
    mailaddress = resource2.Body('mailaddress')
    #: This value is used for language of Deep Security Manager.
    #: ja: Japanese, en: English.
    dsm_lang = resource2.Body('dsm_lang')
    #: Set "Asia/Tokyo" for JST or "Etc/GMT" for UTC.
    time_zone = resource2.Body('time_zone')
    #: Messages are displayed in Japanese or English depending on this value.
    #: ja: Japanese, en: English. Default value is "en".
    locale = resource2.Body('locale')
    #: This value indicates normal or abnormal. 1:normal, 2:abnormal.
    code = resource2.Body('code', alternate_id=True)
    #: This message is shown when error has occurred.
    message = resource2.Body('message')
    #: Identification ID of Service Order.
    soid = resource2.Body('soId')
    #: This value indicates normal or abnormal. 1:normal, 2:abnormal.
    status = resource2.Body('status')
    #: Percentage of Service Order Progress Status.
    progress_rate = resource2.Body('progressRate')
    #: Region tenant you specified belongs to.
    region = resource2.Body('region')
    #: Tenant Name.
    tenant_name = resource2.Body('tenant_name')
    #: Description for this tenant.
    tenant_description = resource2.Body('tenant_description')
    #: Contract ID which this tenant belongs to.
    contract_id = resource2.Body('contract_id')
    #: Customer Name.
    customer_name = resource2.Body('customer_name')
    #: Internal Use. (true: Already applied, false: Not applied.)
    tenant_flg = resource2.Body('tenant_flg')

    def get_order_status(self, session, soid, locale=None):
        tenant_id = session.get_project_id()
        uri = '/API/ScreenEventHBSOrderProgressRate?tenant_id=%s&soid=%s' \
              % (tenant_id, soid)
        if locale is not None:
            uri += '&locale=%s' % locale
        headers = {'Content-Type': 'application/json'}
        resp = session.get(uri, endpoint_filter=self.service, headers=headers)
        self._translate_response(resp, has_body=True)
        return self

    def get_order_info(self, session, locale=None):
        tenant_id = session.get_project_id()
        uri = '/API/ScreenEventHBSOrderInfoGet?tenant_id=%s' % tenant_id
        if locale is not None:
            uri += '&locale=%s' % locale
        headers = {'Content-Type': 'application/json'}
        resp = session.get(uri, endpoint_filter=self.service, headers=headers)
        self._translate_response(resp, has_body=True)
        return self

    def update(self, session, **body):
        uri = self.base_path
        resp = session.post(uri, endpoint_filter=self.service, json=body)
        self._translate_response(resp, has_body=True)
        return self

    def delete(self, session, body, locale=None):
        uri = self.base_path
        resp = session.post(uri, endpoint_filter=self.service, json=body)
        self._translate_response(resp, has_body=True)
        return self