Beispiel #1
0
class VPNInterface(NetworkBaseResource):

    resource_key = "vpn_interface"
    resources_key = "vpn_interfaces"
    base_path = '/v2.0/vpn_interfaces'
    service = network_service.NetworkService()

    allow_list = True
    allow_get = True
    allow_create = True
    allow_update = True
    allow_delete = True

    _query_mapping = resource2.QueryParameters(
        "description", "id",
        "name", "vpn_gw_id",
        "status", "tenant_id",
        "sort_key", "sort_dir",
    )

    description = resource2.Body("description")
    id = resource2.Body("id")
    vpn_gw_id = resource2.Body("vpn_gw_id")
    name = resource2.Body("name")
    status = resource2.Body("status")
    tenant_id = resource2.Body("tenant_id")
    primary = resource2.Body("primary")
    secondary = resource2.Body("secondary")

    def wait_for_interface(self, session, status='ACTIVE', failures=['ERROR'],
                           interval=2, wait=120):
        return resource2.wait_for_status(session, self, status,
                                         failures, interval, wait)
Beispiel #2
0
class ColocationSpace(base.NetworkBaseResource):
    resource_key = 'colocation_space'
    resources_key = 'colocation_spaces'
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/colocation_spaces'

    # capabilities
    allow_get = True
    allow_list = True

    # query mappings
    _query_mapping = resource2.QueryParameters(
        'description',
        'id',
        'name',
        "sort_key",
        "sort_dir",
    )

    # properties
    #: Colocation Space description.
    description = resource2.Body('description')
    #: Colocation Space unique id.
    id = resource2.Body('id')
    #: Colocation Space name.
    name = resource2.Body('name')
Beispiel #3
0
class ReservedAddress(resource2.Resource):
    resource_key = 'reserve_address'
    resources_key = 'reserve_addresses'
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/reserve_addresses'

    _query_mapping = resource2.QueryParameters(
        "subnets",
        "id",
        "destination",
        "sort_key",
        "sort_dir",
    )

    # capabilities
    allow_create = False
    allow_get = True
    allow_update = False
    allow_delete = False
    allow_list = True

    # Properties
    #: id of the reserved address
    id = resource2.Body("id")
    #: subnets cidr of the reserved address
    subnets = resource2.Body("subnets")
    #: tenant id that reserved address belong to
    tenant_id = resource2.Body("tenant_id")
Beispiel #4
0
class GCPInterface(NetworkBaseResource):

    resource_key = "gcp_interface"
    resources_key = "gcp_interfaces"
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/gcp_interfaces'

    allow_list = True
    allow_get = True

    #: GCP Gateway to which this interface is connected.
    gcp_gw_id = resource2.Body("gcp_gw_id")
    #: Description of the GCP Interface resource.
    description = resource2.Body("description")
    #: Unique ID of the GCP Interface resource.
    id = resource2.Body("id")
    #: Name of the GCP Interface resource
    name = resource2.Body("name")
    #: The GCP Interface status.
    status = resource2.Body("status")
    #: Tenant ID of the owner (UUID)
    tenant_id = resource2.Body("tenant_id")
    #: Primary router uplink ip configuration.
    primary = resource2.Body("primary")
    #: Secondary router uplink ip configuration.
    secondary = resource2.Body("secondary")
Beispiel #5
0
class TenantConnection(NetworkBaseResource):
    resource_key = "tenant_connection"
    resources_key = "tenant_connections"

    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/tenant_connections'

    allow_list = True
    allow_get = True
    allow_create = True
    allow_delete = True
    allow_update = True

    _query_mapping = resource2.QueryParameters(
        "approval_request_id", "interface_type",
        "name", "description", "id", "progress",
        "tenant_id", "sort_key", "sort_dir",
    )

    approval_request_id = resource2.Body("approval_request_id")
    connected_interface = resource2.Body("connected_interface", dict)
    connected_network = resource2.Body("connected_network", dict)
    interface_type = resource2.Body("interface_type")
    description = resource2.Body("description")
    id = resource2.Body("id")
    name = resource2.Body("name")
    progress = resource2.Body("progress")
    tenant_id = resource2.Body("tenant_id")

    def execute(self, session):
        """Preform tenant connection execute."""
        url = utils.urljoin(TenantConnection.base_path, self.id, 'execute')
        headers = {'Accept': ''}
        return session.post(
            url, endpoint_filter=self.service, headers=headers)
Beispiel #6
0
class PhysicalPort(resource2.Resource):
    resource_key = 'physical_port'
    resources_key = 'physical_ports'
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/physical_ports'

    # capabilities
    allow_get = True
    allow_list = True

    # properties
    #: Physical port description.
    description = resource2.Body('description')
    #: Physical port unique id.
    id = resource2.Body('id')
    #: Physical port name.
    name = resource2.Body('name')
    #: The type of traffic that port will be used.
    plane = resource2.Body('plane')
    #: Ranges of allowed VLAN tags.
    segmentation_ranges = resource2.Body('segmentation_ranges')
    #: The ID of service that owns the physical port.
    service_id = resource2.Body('service_id')
    #: The type of physical port service owner.
    service_owner = resource2.Body('service_owner')
    #: The Physical Port status.
    status = resource2.Body('status')
    #: Port tags.
    tags = resource2.Body('tags')
    #: The owner name of physical port.
    tenant_id = resource2.Body('tenant_id')
Beispiel #7
0
class StaticRoute(NetworkBaseResource):

    resource_key = "static_route"
    resources_key = "static_routes"
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/static_routes'

    allow_list = True
    allow_get = True
    allow_create = True
    allow_delete = True
    allow_update = True

    _query_mapping = resource2.QueryParameters(
        "description",
        "id",
        "destination",
        "name",
        "interdc_gw_id",
        "internet_gw_id",
        "nexthop",
        "service_type",
        "status",
        "tenant_id",
        "vpn_gw_id",
        "sort_key",
        "sort_dir",
        "aws_gw_id",
        "azure_gw_id",
        "gcp_gw_id",
        "fic_gw_id",
    )

    description = resource2.Body("description")
    destination = resource2.Body("destination")
    id = resource2.Body("id")
    interdc_gw_id = resource2.Body("interdc_gw_id")
    internet_gw_id = resource2.Body("internet_gw_id")
    name = resource2.Body("name")
    nexthop = resource2.Body("nexthop")
    service_type = resource2.Body("service_type")
    status = resource2.Body("status")
    tenant_id = resource2.Body("tenant_id")
    vpn_gw_id = resource2.Body("vpn_gw_id")
    aws_gw_id = resource2.Body("aws_gw_id")
    gcp_gw_id = resource2.Body("gcp_gw_id")
    azure_gw_id = resource2.Body("azure_gw_id")
    fic_gw_id = resource2.Body("fic_gw_id")

    def wait_for_create(self,
                        session,
                        status='ACTIVE',
                        failures=['ERROR'],
                        interval=2,
                        wait=120):
        return resource2.wait_for_status(session, self, status, failures,
                                         interval, wait)
Beispiel #8
0
 def test_service(self):
     sot = network_service.NetworkService()
     self.assertEqual('network', 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.0', sot.valid_versions[0].path)
class ColocationPhysicalLink(base.NetworkBaseResource):
    resource_key = 'colocation_physical_link'
    resources_key = 'colocation_physical_links'
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/colocation_physical_links'

    # capabilities
    allow_get = True
    allow_list = True

    # query mappings
    _query_mapping = resource2.QueryParameters(
        'bandwidth',
        'colocation_space_id',
        'description',
        'id',
        'name',
        'status',
        'tenant_id',
        'type_a_physical_port_id',
        'type_a_rack_id',
        'type_b_physical_port_id',
        'type_b_rack_id',
        'colocation_physical_link_id',
        "sort_key",
        "sort_dir",
    )

    # properties
    #: The bandwidth of Colocation Physical Link.
    bandwidth = resource2.Body('bandwidth')
    #: Colocation Space ID.
    colocation_space_id = resource2.Body('colocation_space_id')
    #: Colocation Physical Link description.
    description = resource2.Body('description')
    #: Colocation Physical Link unique id.
    id = resource2.Body('id')
    #: Colocation Physical Link name.
    name = resource2.Body('name')
    #: Ranges of allowed VLAN tags.
    segmentation_ranges = resource2.Body('segmentation_ranges')
    #: The Colocation Physical Link status.
    status = resource2.Body('status')
    #: Colocation Physical Link tags.
    tags = resource2.Body('tags')
    #: The owner name of Colocation Physical Link.
    tenant_id = resource2.Body('tenant_id')
    #: Type A Physical Port ID.
    type_a_physical_port_id = resource2.Body('type_a_physical_port_id')
    #: Type A Rack ID.
    type_a_rack_id = resource2.Body('type_a_rack_id')
    #: Type B Physical Port ID.
    type_b_physical_port_id = resource2.Body('type_b_physical_port_id')
    #: Type B Rack ID.
    type_b_rack_id = resource2.Body('type_b_rack_id')
Beispiel #10
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())
class ColocationLogicalLink(base.NetworkBaseResource):
    resource_key = 'colocation_logical_link'
    resources_key = 'colocation_logical_links'
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/colocation_logical_links'

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

    # query mappings
    _query_mapping = resource2.QueryParameters(
        'bandwidth',
        'colocation_physical_link_id',
        'description',
        'id',
        'name',
        'network_id',
        'status',
        'tenant_id',
        'type_a_port_id',
        'type_b_port_id',
        'vlan_id',
        "sort_key",
        "sort_dir",
    )

    # properties
    #: Colocation Physical Link ID.
    colocation_physical_link_id = resource2.Body('colocation_physical_link_id')
    #: Colocation Logical Link description.
    description = resource2.Body('description')
    #: Colocation Logical Link unique id.
    id = resource2.Body('id')
    #: Colocation Logical Link name.
    name = resource2.Body('name')
    #: Network connected to this link.
    network_id = resource2.Body('network_id')
    #: The Colocation Logical Link status.
    status = resource2.Body('status')
    #: Colocation Logical Link tags.
    tags = resource2.Body('tags')
    #: The owner name of Colocation Logical Link.
    tenant_id = resource2.Body('tenant_id')
    #: Type A Port ID.
    type_a_port_id = resource2.Body('type_a_port_id')
    #: Type B Port ID.
    type_b_port_id = resource2.Body('type_b_port_id')
    #: Logical port vlan id.
    vlan_id = resource2.Body('vlan_id')
Beispiel #12
0
class Version(resource.Resource):
    resource_key = 'version'
    resources_key = 'versions'
    base_path = '/'
    service = network_service.NetworkService(
        version=network_service.NetworkService.UNVERSIONED)

    # capabilities
    allow_list = True

    # Properties
    links = resource.prop('links')
    status = resource.prop('status')
Beispiel #13
0
class AWSService(NetworkBaseResource):

    resource_key = "aws_service"
    resources_key = "aws_services"
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/aws_services'

    allow_list = True
    allow_get = True

    description = resource2.Body("description")
    id = resource2.Body("id")
    zone = resource2.Body("zone")
    name = resource2.Body("name")
Beispiel #14
0
class InterDCService(NetworkBaseResource):

    resource_key = "interdc_service"
    resources_key = "interdc_services"
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/interdc_services'

    allow_list = True
    allow_get = True

    _query_mapping = resource2.QueryParameters("description", "id", "zone",
                                               "name")

    description = resource2.Body("description")
    id = resource2.Body("id")
    zone = resource2.Body("zone")
    name = resource2.Body("name")
Beispiel #15
0
class AWSGateway(NetworkBaseResource):

    resource_key = "aws_gateway"
    resources_key = "aws_gateways"
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/aws_gateways'

    allow_list = True
    allow_get = True

    description = resource2.Body("description")
    id = resource2.Body("id")
    aws_service_id = resource2.Body("aws_service_id")
    name = resource2.Body("name")
    qos_option_id = resource2.Body("qos_option_id")
    status = resource2.Body("status")
    tenant_id = resource2.Body("tenant_id")
Beispiel #16
0
class GCPService(NetworkBaseResource):

    resource_key = "gcp_service"
    resources_key = "gcp_services"
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/gcp_services'

    allow_list = True
    allow_get = True

    #: Description of the GCP Service resource.
    description = resource2.Body("description")
    #: Unique ID of the GCP Service resource.
    id = resource2.Body("id")
    #: Name of zone.
    zone = resource2.Body("zone")
    #: Name of the GCP Service resource.
    name = resource2.Body("name")
Beispiel #17
0
class AWSInterface(NetworkBaseResource):

    resource_key = "aws_interface"
    resources_key = "aws_interfaces"
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/aws_interfaces'

    allow_list = True
    allow_get = True

    aws_gw_id = resource2.Body("aws_gw_id")
    description = resource2.Body("description")
    id = resource2.Body("id")
    name = resource2.Body("name")
    status = resource2.Body("status")
    tenant_id = resource2.Body("tenant_id")
    primary = resource2.Body("primary")
    secondary = resource2.Body("secondary")
Beispiel #18
0
class Quota(resource2.Resource):
    resource_key = 'quota'
    resources_key = 'quotas'
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/quotas'

    # capabilities
    allow_get = True
    allow_update = True
    allow_delete = True
    allow_list = True

    # Properties
    #: The maximum amount of colocation logical link you can have. *Type: int*
    colocation_logical_link = resource2.Body('colocation_logical_link',
                                             type=int)
    #: The maximum amount of common function gateway you can create. *Type: int*
    common_function_gateway = resource2.Body('common_function_gateway',
                                             type=int)
    #: The maximum amount of fic gateway you can create. *Type: int*
    fic_gateway = resource2.Body('fic_gateway', type=int)
    #: The maximum amount of firewall you can create. *Type: int*
    firewall = resource2.Body('firewall', type=int)
    #: ID of quota
    id = resource2.Body("id")
    #: The maximum amount of interdc gateway you can create. *Type: int*
    interdc_gateway = resource2.Body('interdc_gateway', type=int)
    #: The maximum amount of internet gateway you can create. *Type: int*
    internet_gateway = resource2.Body('internet_gateway', type=int)
    #: The maximum amount of networks you can create. *Type: int*
    network = resource2.Body('network', type=int)
    #: The maximum amount of load balancer you can create. *Type: int*
    load_balancer = resource2.Body('load_balancer', type=int)
    #: The maximum amount of ports you can create. *Type: int*
    port = resource2.Body('port', type=int)
    #: The ID of the project these quota values are for.
    project_id = resource2.Body('tenant_id')
    #: The maximum amount of subnets you can create. *Type: int*
    subnet = resource2.Body('subnet', type=int)
    #: The maximum amount of vpn gateway you can create. *Type: int*
    vpn_gateway = resource2.Body('vpn_gateway', type=int)
    #: The maximum amount of public ip you can create. *Type: int*
    public_ip = resource2.Body('public_ip', type=int)
Beispiel #19
0
class PublicIP(NetworkBaseResource):

    resource_key = "public_ip"
    resources_key = "public_ips"
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/public_ips'

    _query_mapping = resource2.QueryParameters(
        "cidr",
        "description",
        "id",
        "internet_gw_id",
        "name",
        "status",
        "submask_length",
        "tenant_id",
        "sort_key",
        "sort_dir",
    )

    allow_list = True
    allow_get = True
    allow_create = True
    allow_delete = True
    allow_update = True

    cidr = resource2.Body("cidr")
    description = resource2.Body("description")
    id = resource2.Body("id")
    internet_gw_id = resource2.Body("internet_gw_id")
    name = resource2.Body("name")
    status = resource2.Body("status")
    submask_length = resource2.Body("submask_length", int)
    tenant_id = resource2.Body("tenant_id")

    def wait_for_publicip(self,
                          session,
                          status='ACTIVE',
                          failures=['ERROR'],
                          interval=2,
                          wait=120):
        return resource2.wait_for_status(session, self, status, failures,
                                         interval, wait)
Beispiel #20
0
class LoadBalancerAction(resource2.Resource):
    service = network_service.NetworkService("v2.0")
    base_path = ('/' + service.version +
                 "/load_balancers/%(load_balancer_id)s/%(action)s")

    # Capabilities
    allow_get = True
    allow_create = True

    # Properties
    #: New password reset.
    new_password = resource2.Body("new_password")
    #: Username of the load balancer.
    username = resource2.Body("username")

    def reboot(self, session, load_balancer_id, type):
        """Reboot load balancer."""

        uri = self.base_path % {
            "load_balancer_id": load_balancer_id,
            "action": "reboot"
        }
        resp = session.post(uri,
                            endpoint_filter=self.service,
                            json={"type": type})
        self._translate_response(resp, has_body=False)
        return self

    def reset_password(self, session, load_balancer_id, username):
        """Reset password of load balancer instance."""

        uri = self.base_path % {
            "load_balancer_id": load_balancer_id,
            "action": "reset_password"
        }
        resp = session.post(uri,
                            endpoint_filter=self.service,
                            json={"username": username})
        self._translate_response(resp, has_body=True)
        return self
Beispiel #21
0
class GCPGateway(NetworkBaseResource):

    resource_key = "gcp_gateway"
    resources_key = "gcp_gateways"
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/gcp_gateways'

    allow_list = True
    allow_get = True

    #: Description of the GCP Gateway resource.
    description = resource2.Body("description")
    #: Unique ID of the GCP Gateway resource.
    id = resource2.Body("id")
    #: GCP Service instantiated by this Gateway.
    gcp_service_id = resource2.Body("gcp_service_id")
    #: Name of the GCP Gateway resource.
    name = resource2.Body("name")
    #: Quality of Service options selected for this Gateway.
    qos_option_id = resource2.Body("qos_option_id")
    #: The GCP Gateway status.
    status = resource2.Body("status")
    #: Tenant ID of the owner (UUID)
    tenant_id = resource2.Body("tenant_id")
Beispiel #22
0
class CommonFunction(base.NetworkBaseResource):
    resource_key = 'common_function'
    resources_key = 'common_functions'
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/common_functions'

    _query_mapping = resource2.QueryParameters(
        "description",
        "id",
        "link_local_ip_address",
        "name",
        "status",
        "sort_key",
        "sort_dir",
    )

    # capabilities
    allow_get = True
    allow_list = True

    # properties
    #: Description of the Common Function resource.
    description = resource2.Body('description')
    #: Unique ID of the Common Function resource.
    id = resource2.Body('id')
    #: Link-local IP address of Common Function (after NAT).
    link_local_ip_address = resource2.Body('link_local_ip_address')
    #: Name of the Common Function resource.
    name = resource2.Body('name')
    #: Hidden Common Function status.
    status = resource2.Body('status')

    @classmethod
    def find(cls, session, name_or_id, ignore_missing=False, **params):
        """Find a resource by its name or id.

        :param session: The session to use for making this request.
        :type session: :class:`~ecl.session.Session`
        :param name_or_id: This resource's identifier, if needed by
                           the request. The default is ``None``.
        :param bool ignore_missing: When set to ``False``
                    :class:`~ecl.exceptions.ResourceNotFound` will be
                    raised when the resource does not exist.
                    When set to ``True``, None will be returned when
                    attempting to find a nonexistent resource.
        :param dict params: Any additional parameters to be passed into
                            underlying methods, such as to
                            :meth:`~ecl.resource2.Resource.existing`
                            in order to pass on URI parameters.

        :return: The :class:`Resource` object matching the given name or id
                 or None if nothing matches.
        :raises: :class:`ecl.exceptions.DuplicateResource` if more
                 than one resource is found for this request.
        :raises: :class:`ecl.exceptions.ResourceNotFound` if nothing
                 is found and ignore_missing is ``False``.
        """
        # Try to short-circuit by looking directly for a matching ID.

        data = cls.list(session, **params)

        result = cls._get_one_match(name_or_id, data)
        if result is not None:
            return result

        if ignore_missing:
            return None
        raise exceptions.ResourceNotFound("No %s found for %s" %
                                          (cls.__name__, name_or_id))
Beispiel #23
0
class GatewayInterface(NetworkBaseResource):

    resource_key = "gw_interface"
    resources_key = "gw_interfaces"
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/gw_interfaces'

    _query_mapping = resource2.QueryParameters(
        "description", "gw_vipv4", "gw_vipv6",
        "id", "interdc_gw_id", "internet_gw_id",
        "name", "netmask", "network_id",
        "primary_ipv4", "primary_ipv6",
        "secondary_ipv4", "secondary_ipv6",
        "service_type", "vpn_gw_id",
        "status", "tenant_id", "vrid",
        "sort_key", "sort_dir", "aws_gw_id",
        "azure_gw_id", "gcp_gw_id", "fic_gw_id",
    )

    allow_list = True
    allow_get = True
    allow_create = True
    allow_delete = True
    allow_update = True

    description = resource2.Body("description")
    gw_vipv4 = resource2.Body("gw_vipv4")
    gw_vipv6 = resource2.Body("gw_vipv6")
    id = resource2.Body("id")
    interdc_gw_id = resource2.Body("interdc_gw_id")
    internet_gw_id = resource2.Body("internet_gw_id")
    name = resource2.Body("name")
    netmask = resource2.Body("netmask")
    network_id = resource2.Body("network_id")
    primary_ipv4 = resource2.Body("primary_ipv4")
    primary_ipv6 = resource2.Body("primary_ipv6")
    secondary_ipv4 = resource2.Body("secondary_ipv4")
    secondary_ipv6 = resource2.Body("secondary_ipv6")
    service_type = resource2.Body("service_type")
    status = resource2.Body("status")
    tenant_id = resource2.Body("tenant_id")
    vpn_gw_id = resource2.Body("vpn_gw_id")
    aws_gw_id = resource2.Body("aws_gw_id")
    gcp_gw_id = resource2.Body("gcp_gw_id")
    azure_gw_id = resource2.Body("azure_gw_id")
    fic_gw_id = resource2.Body("fic_gw_id")
    vrid = resource2.Body("vrid")

    def wait_for_create(self, session, status='ACTIVE', failures=['ERROR'],
                         interval=2, wait=120):
        return resource2.wait_for_status(session, self, status,
                                         failures, interval, wait)

    @classmethod
    def find(cls, session, name_or_id, ignore_missing=False, **params):
        """Find a resource by its name or id.

        :param session: The session to use for making this request.
        :type session: :class:`~ecl.session.Session`
        :param name_or_id: This resource's identifier, if needed by
                           the request. The default is ``None``.
        :param bool ignore_missing: When set to ``False``
                    :class:`~ecl.exceptions.ResourceNotFound` will be
                    raised when the resource does not exist.
                    When set to ``True``, None will be returned when
                    attempting to find a nonexistent resource.
        :param dict params: Any additional parameters to be passed into
                            underlying methods, such as to
                            :meth:`~ecl.resource2.Resource.existing`
                            in order to pass on URI parameters.

        :return: The :class:`Resource` object matching the given name or id
                 or None if nothing matches.
        :raises: :class:`ecl.exceptions.DuplicateResource` if more
                 than one resource is found for this request.
        :raises: :class:`ecl.exceptions.ResourceNotFound` if nothing
                 is found and ignore_missing is ``False``.
        """
        # Try to short-circuit by looking directly for a matching ID.

        data = cls.list(session, **params)

        result = cls._get_one_match(name_or_id, data)
        if result is not None:
            return result

        if ignore_missing:
            return None
        raise exceptions.ResourceNotFound(
            "No %s found for %s" % (cls.__name__, name_or_id))
Beispiel #24
0
class Subnet(base.NetworkBaseResource):
    resource_key = 'subnet'
    resources_key = 'subnets'
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/subnets'

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

    # query mappings
    _query_mapping = resource2.QueryParameters(
        'cidr',
        'description',
        'gateway_ip',
        'id',
        'ip_version',
        'ipv6_address_mode',
        'ipv6_ra_mode',
        'name',
        'network_id',
        'status',
        'tenant_id',
        'subnet_id',
        'sort_key',
        'sort_dir',
    )

    # Properties
    #: The start and end addresses for the allocation pools.
    allocation_pools = resource2.Body('allocation_pools')
    #: The CIDR.
    cidr = resource2.Body('cidr')
    #: The subnet description.
    description = resource2.Body('description')
    #: A list of DNS nameservers.
    dns_nameservers = resource2.Body('dns_nameservers')
    #: The gateway IP address.
    gateway_ip = resource2.Body('gateway_ip')
    #: Subnet unique id.
    id = resource2.Body('id')
    #: A list of host routes.
    host_routes = resource2.Body('host_routes')
    #: A list of ntp servers.
    ntp_servers = resource2.Body('ntp_servers')
    #: The IP version, which is ``4`` or ``6``.
    ip_version = resource2.Body('ip_version')
    #: The IPv6 address modes which are 'dhcpv6-stateful', 'dhcpv6-stateless',
    #: or 'SLAAC'
    ipv6_address_mode = resource2.Body('ipv6_address_mode')
    #: The IPv6 router advertisements modes
    ipv6_ra_mode = resource2.Body('ipv6_ra_mode')
    #: Set to ``True`` if DHCP is enabled and ``False`` if DHCP is disabled.
    #: *Type: bool*
    enable_dhcp = resource2.Body('enable_dhcp', type=bool)
    #: The subnet name.
    name = resource2.Body('name')
    #: The ID of the attached network.
    network_id = resource2.Body('network_id')
    #: The ID of the project this subnet is associated with.
    project_id = resource2.Body('tenant_id')
    #: The status of the subnet
    status = resource2.Body('status')
    #: tags of the subnet
    tags = resource2.Body('tags')

    @classmethod
    def find(cls, session, name_or_id, ignore_missing=False, **params):
        """Find a resource by its name or id.

        :param session: The session to use for making this request.
        :type session: :class:`~ecl.session.Session`
        :param name_or_id: This resource's identifier, if needed by
                           the request. The default is ``None``.
        :param bool ignore_missing: When set to ``False``
                    :class:`~ecl.exceptions.ResourceNotFound` will be
                    raised when the resource does not exist.
                    When set to ``True``, None will be returned when
                    attempting to find a nonexistent resource.
        :param dict params: Any additional parameters to be passed into
                            underlying methods, such as to
                            :meth:`~ecl.resource2.Resource.existing`
                            in order to pass on URI parameters.

        :return: The :class:`Resource` object matching the given name or id
                 or None if nothing matches.
        :raises: :class:`ecl.exceptions.DuplicateResource` if more
                 than one resource is found for this request.
        :raises: :class:`ecl.exceptions.ResourceNotFound` if nothing
                 is found and ignore_missing is ``False``.
        """
        # Try to short-circuit by looking directly for a matching ID.

        data = cls.list(session, **params)

        result = cls._get_one_match(name_or_id, data)
        if result is not None:
            return result

        if ignore_missing:
            return None
        raise exceptions.ResourceNotFound("No %s found for %s" %
                                          (cls.__name__, name_or_id))
Beispiel #25
0
class LoadBalancer(base.NetworkBaseResource):

    resource_key = "load_balancer"
    resources_key = "load_balancers"
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/load_balancers'

    _query_mapping = resource2.QueryParameters(
        "admin_username",
        "availability_zone",
        "default_gateway",
        "description",
        "id",
        "load_balancer_plan_id",
        "name",
        "status",
        "tenant_id",
        "user_username",
        "sort_key",
        "sort_dir",
    )

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

    # Properties
    #: Admin's password placeholder.
    admin_password = resource2.Body("admin_password")
    #: Username with admin access to VM instance.
    admin_username = resource2.Body("admin_username")
    #: Availability Zone.
    availability_zone = resource2.Body("availability_zone")
    #: IP address of default gateway.
    default_gateway = resource2.Body("default_gateway")
    #: Description of the Load Balancer.
    description = resource2.Body("description")
    #: Unique ID of the Load Balancer.
    id = resource2.Body("id")
    #: Load Balancer Plan
    load_balancer_plan_id = resource2.Body("load_balancer_plan_id")
    #: Name of the Load Balancer
    name = resource2.Body("name")
    #: The load_balancer status.
    status = resource2.Body("status")
    #: Tenant ID of the owner (UUID)
    tenant_id = resource2.Body("tenant_id")
    #: Username with user access to VM instance
    user_username = resource2.Body("user_username")
    #: User's password placeholder
    user_password = resource2.Body("user_password")
    #: Attached interfaces:
    #: interfaces.id: Unique ID of the Load Balancer Interface
    #: interfaces.ip_address: IP Address
    #: interfaces.name: Name the Load Balancer Interface
    #: interfaces.network_id: Network
    #: interfaces.slot_number: Slot Number
    #: interfaces.status: Load Balancer Interface status
    #: interfaces.type: Load Balancer Interface Type
    #: interfaces.virtual_ip_address: Virtual IP Address
    #: interfaces.virtual_ip_properties: Properties used for virtual IP address.
    interfaces = resource2.Body("interfaces")

    def update(self, session, load_balancer_id, **attrs):
        """Update a load balancer."""

        uri = utils.urljoin(self.base_path, load_balancer_id)
        resp = session.put(uri, endpoint_filter=self.service, json=attrs)
        self._translate_response(resp, has_body=True)
        return self

    @classmethod
    def find(cls, session, name_or_id, ignore_missing=False, **params):
        """Find a resource by its name or id.

        :param session: The session to use for making this request.
        :type session: :class:`~ecl.session.Session`
        :param name_or_id: This resource's identifier, if needed by
                           the request. The default is ``None``.
        :param bool ignore_missing: When set to ``False``
                    :class:`~ecl.exceptions.ResourceNotFound` will be
                    raised when the resource does not exist.
                    When set to ``True``, None will be returned when
                    attempting to find a nonexistent resource.
        :param dict params: Any additional parameters to be passed into
                            underlying methods, such as to
                            :meth:`~ecl.resource2.Resource.existing`
                            in order to pass on URI parameters.

        :return: The :class:`Resource` object matching the given name or id
                 or None if nothing matches.
        :raises: :class:`ecl.exceptions.DuplicateResource` if more
                 than one resource is found for this request.
        :raises: :class:`ecl.exceptions.ResourceNotFound` if nothing
                 is found and ignore_missing is ``False``.
        """
        # Try to short-circuit by looking directly for a matching ID.

        data = cls.list(session, **params)

        result = cls._get_one_match(name_or_id, data)
        if result is not None:
            return result

        if ignore_missing:
            return None
        raise exceptions.ResourceNotFound("No %s found for %s" %
                                          (cls.__name__, name_or_id))
Beispiel #26
0
class LoadBalancerSyslogServer(base.NetworkBaseResource):

    resources_key = "load_balancer_syslog_servers"
    resource_key = "load_balancer_syslog_server"
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + "/load_balancer_syslog_servers"

    _query_mapping = resource2.QueryParameters(
        "acl_logging",
        "appflow_logging",
        "date_format",
        "description",
        "id",
        "ip_address",
        "load_balancer_id",
        "log_facility",
        "log_level",
        "name",
        "port_number",
        "priority",
        "status",
        "tcp_logging",
        "tenant_id",
        "time_zone",
        "transport_type",
        "user_configurable_log_messages",
        "sort_key",
        "sort_dir",
    )
    # Capabilities
    allow_list = True
    allow_get = True
    allow_update = True
    allow_delete = True
    allow_create = True

    # Properties
    acl_logging = resource2.Body("acl_logging")

    appflow_logging = resource2.Body("appflow_logging")

    date_format = resource2.Body("date_format")

    #: Description of the Load Balancer Syslog Server.
    description = resource2.Body("description")

    #: Unique ID of the Load Balancer Syslog Server.
    id = resource2.Body("id")

    #: IP Address
    ip_address = resource2.Body("ip_address")

    #: The ID of load_balancer this load_balancer_interface belongs to.
    load_balancer_id = resource2.Body("load_balancer_id")

    log_facility = resource2.Body("log_facility")

    log_level = resource2.Body("log_level")

    #: Name of the Load Balancer
    name = resource2.Body("name")

    #: Port Number
    port_number = resource2.Body("port_number")

    #: Priority
    priority = resource2.Body("priority")

    #: The load_balancer Syslog Server status.
    status = resource2.Body("status")

    tcp_logging = resource2.Body("tcp_logging")

    #: Tenant ID of the owner (UUID)
    tenant_id = resource2.Body("tenant_id")

    #: Timezone
    time_zone = resource2.Body("time_zone")

    transport_type = resource2.Body("transport_type")

    user_configurable_log_messages = resource2.Body(
        "user_configurable_log_messages")
Beispiel #27
0
class FirewallInterface(base.NetworkBaseResource):
    resource_key = "firewall_interface"
    resources_key = "firewall_interfaces"
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + "/firewall_interfaces"

    _query_mapping = resource2.QueryParameters(
        "description",
        "firewall_id",
        "id",
        "ip_address",
        "name",
        "network_id",
        "slot_number",
        "status",
        "tenant_id",
        "virtual_ip_address",
        "sort_key",
        "sort_dir",
    )

    # Capabilities
    allow_get = True
    allow_list = True
    allow_update = True

    # Properties
    #: Description the Firewall Interface.
    description = resource2.Body("description")
    #: The ID of firewall this firewall_interface belongs to.
    firewall_id = resource2.Body("firewall_id")
    #: Unique ID of the Firewall Interface.
    id = resource2.Body("id")
    #: IP Address.
    ip_address = resource2.Body("ip_address")
    #: Name the Firewall Interface.
    name = resource2.Body("name")
    #: Network ID.
    network_id = resource2.Body("network_id")
    #: Slot Number.
    slot_number = resource2.Body("slot_number")
    #: Firewall interface status.
    status = resource2.Body("status")
    #: Tenant ID of the owner (UUID).
    tenant_id = resource2.Body("tenant_id")
    #: Virtual IP Address.
    virtual_ip_address = resource2.Body("virtual_ip_address")
    #: Properties used for virtual IP address.
    virtual_ip_properties = resource2.Body("virtual_ip_properties")

    #: VRID of Firewall virtual ip properties
    @property
    def vrid(self):
        virtual_ip_properties = self._body['virtual_ip_properties']
        if virtual_ip_properties is None:
            return
        else:
            return virtual_ip_properties['vrid']

    def update(self, session, firewall_id, firewall_interface_id, **attrs):
        """Update a firewall interface."""
        update_path = '/' + self.service.version
        uri = utils.urljoin(update_path, 'firewalls', firewall_id,
                            'firewall_interfaces', firewall_interface_id)
        resp = session.put(uri, endpoint_filter=self.service, json=attrs)
        self._translate_response(resp, has_body=True)
        return self
Beispiel #28
0
class InternetService(NetworkBaseResource):

    resource_key = "internet_service"
    resources_key = "internet_services"
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/internet_services'

    allow_list = True
    allow_get = True

    _query_mapping = resource2.QueryParameters(
        "description",
        "id",
        "minimal_subnet_length",
        "zone",
        "name",
        "sort_key",
        "sort_dir",
    )

    description = resource2.Body("description")
    id = resource2.Body("id")
    minimal_submask_length = resource2.Body("minimal_submask_length")
    zone = resource2.Body("zone")
    name = resource2.Body("name")

    @classmethod
    def find(cls, session, name_or_id, ignore_missing=False, **params):
        """Find a resource by its name or id.

        :param session: The session to use for making this request.
        :type session: :class:`~ecl.session.Session`
        :param name_or_id: This resource's identifier, if needed by
                           the request. The default is ``None``.
        :param bool ignore_missing: When set to ``False``
                    :class:`~ecl.exceptions.ResourceNotFound` will be
                    raised when the resource does not exist.
                    When set to ``True``, None will be returned when
                    attempting to find a nonexistent resource.
        :param dict params: Any additional parameters to be passed into
                            underlying methods, such as to
                            :meth:`~ecl.resource2.Resource.existing`
                            in order to pass on URI parameters.

        :return: The :class:`Resource` object matching the given name or id
                 or None if nothing matches.
        :raises: :class:`ecl.exceptions.DuplicateResource` if more
                 than one resource is found for this request.
        :raises: :class:`ecl.exceptions.ResourceNotFound` if nothing
                 is found and ignore_missing is ``False``.
        """
        # Try to short-circuit by looking directly for a matching ID.

        data = cls.list(session, **params)

        result = cls._get_one_match(name_or_id, data)
        if result is not None:
            return result

        if ignore_missing:
            return None
        raise exceptions.ResourceNotFound("No %s found for %s" %
                                          (cls.__name__, name_or_id))
Beispiel #29
0
class LoadBalancerInterface(base.NetworkBaseResource):

    resources_key = "load_balancer_interfaces"
    resource_key = "load_balancer_interface"
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + "/load_balancer_interfaces"

    _query_mapping = resource2.QueryParameters(
        "description",
        "id",
        "ip_address",
        "load_balancer_id",
        "name",
        "network_id",
        "slot_number",
        "status",
        "tenant_id",
        "virtual_ip_address",
        "sort_key",
        "sort_dir",
    )

    # Capabilities
    allow_list = True
    allow_get = True
    allow_update = True

    # Properties
    #: Description of the Load Balancer Interface.
    description = resource2.Body("description")
    #: Unique ID of the Load Balancer Interface.
    id = resource2.Body("id")
    #: IP Address
    ip_address = resource2.Body("ip_address")
    #: The ID of load_balancer this load_balancer_interface belongs to.
    load_balancer_id = resource2.Body("load_balancer_id")
    #: Name of the Load Balancer
    name = resource2.Body("name")
    #: Network
    network_id = resource2.Body("network_id")
    #: Slot Number
    slot_number = resource2.Body("slot_number")
    #: The load_balancer status.
    status = resource2.Body("status")
    #: Tenant ID of the owner (UUID)
    tenant_id = resource2.Body("tenant_id")
    #: Virtual IP Address
    virtual_ip_address = resource2.Body("virtual_ip_address")
    #: Properties used for virtual IP address.
    #: virtual_ip_properties.protocol: Redundancy Protocol.
    #: virtual_ip_properties.vrid: VRRP group identifier.
    virtual_ip_properties = resource2.Body("virtual_ip_properties")

    def update(self, session, load_balancer_id, load_balancer_interface_id,
               **attrs):
        """Update a load balancer interface."""
        update_path = '/' + self.service.version
        uri = utils.urljoin(update_path, 'load_balancers', load_balancer_id,
                            'load_balancer_interfaces',
                            load_balancer_interface_id)
        resp = session.put(uri, endpoint_filter=self.service, json=attrs)
        self._translate_response(resp, has_body=True)
        return self
Beispiel #30
0
class Extension(resource2.Resource):
    resource_key = 'extension'
    resources_key = 'extensions'
    service = network_service.NetworkService("v2.0")
    base_path = '/' + service.version + '/extensions'

    # capabilities
    allow_get = True
    allow_list = True

    # Properties
    #: An alias the extension is known under.
    alias = resource2.Body('alias')
    #: Text describing what the extension does.
    description = resource2.Body('description')
    #: The id of this extension.
    id = resource2.Body('id')
    #: Description links
    links = resource2.Body('links', type=list)
    #: The name of this extension.
    name = resource2.Body('name')
    #: A URL pointing to the namespace for this extension.
    namespace = resource2.Body('namespace')
    #: Timestamp when the extension was last updated.
    updated_at = resource2.Body('updated')

    @classmethod
    def find(cls, session, name_or_id, ignore_missing=False, **params):
        """Find a resource by its name or id.

        :param session: The session to use for making this request.
        :type session: :class:`~ecl.session.Session`
        :param name_or_id: This resource's identifier, if needed by
                           the request. The default is ``None``.
        :param bool ignore_missing: When set to ``False``
                    :class:`~ecl.exceptions.ResourceNotFound` will be
                    raised when the resource does not exist.
                    When set to ``True``, None will be returned when
                    attempting to find a nonexistent resource.
        :param dict params: Any additional parameters to be passed into
                            underlying methods, such as to
                            :meth:`~ecl.resource2.Resource.existing`
                            in order to pass on URI parameters.

        :return: The :class:`Resource` object matching the given name or id
                 or None if nothing matches.
        :raises: :class:`ecl.exceptions.DuplicateResource` if more
                 than one resource is found for this request.
        :raises: :class:`ecl.exceptions.ResourceNotFound` if nothing
                 is found and ignore_missing is ``False``.
        """
        # Try to short-circuit by looking directly for a matching ID.

        data = cls.list(session, **params)

        result = cls._get_one_match(name_or_id, data)
        if result is not None:
            return result

        if ignore_missing:
            return None
        raise exceptions.ResourceNotFound("No %s found for %s" %
                                          (cls.__name__, name_or_id))