Beispiel #1
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 #2
0
class CIC(resource2.Resource):

    resource_key = None
    resources_key = None
    base_path = '/mCICs/%(mcic_id)s/CICs'
    service = connectivity_service.ConnectivityService()

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

    _query_mapping = resource2.QueryParameters("sort_key", "sort_dir")

    cic_id = resource2.Body("cic_id", alternate_id=True)
    cic_name = resource2.Body("cic_name")
    cic_status = resource2.Body("cic_status")
    network_id = resource2.Body("network_id")
    network_name = resource2.Body("network_name")
    destination_vlan = resource2.Body("destination_vlan", type=int)
    colo_vlan = resource2.Body("colo_vlan", type=int)
    bandwidth = resource2.Body("bandwidth", type=int)
    mcic_id = resource2.URI("mcic_id")

    def update(self, session, mcic_id, cic_id, has_body=True, **attrs):
        uri = self.base_path % ({'mcic_id': mcic_id})
        uri = utils.urljoin(uri, cic_id)
        args = {'json': attrs}
        resp = session.put(uri, endpoint_filter=self.service, **args)
        self._translate_response(resp, has_body=False)
        return self
Beispiel #3
0
class Operation(resource2.Resource):
    resources_key = "operations"
    service = provider_connectivity_service.ProviderConnectivityService("v1.0")
    base_path = '/' + service.version + '/icc/operations'

    # Capabilities
    allow_list = True

    _query_mapping = resource2.QueryParameters("connection_id",)

    # Properties
    #: It identifies connection resource uniquely.
    connection_id = resource2.Body('connection_id', alternate_id=True)
    #: order type.
    order_type = resource2.Body('order_type')
    #: operation phase.
    phase = resource2.Body('phase')
    #: Status of phase.
    operation_status = resource2.Body('operation_status')
    #: reception datetime. YYYY-MM-DD HH:MM:SS format.
    reception_datetime = resource2.Body('reception_datetime')
    #: commit datetime. YYYY-MM-DD HH:MM:SS format.
    commit_datetime = resource2.Body('commit_datetime')
    #: Request body is stored.
    request_body = resource2.Body('request_body')
Beispiel #4
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 #5
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 #6
0
class License(resource2.Resource):
    resources_key = "licenses"
    resource_key = "license"
    base_path = '/licenses'
    service = dedicated_hypervisor_service.DedicatedHypervisorService()

    # Capabilities
    allow_list = True
    allow_create = True
    allow_delete = True

    _query_mapping = resource2.QueryParameters("license_type")

    # Properties
    #: id of Guest Image license.
    id = resource2.Body('id')
    #: license key.
    key = resource2.Body('key')
    #: date the license assigned from.
    assigned_from = resource2.Body('assigned_from')
    #: expiration date for the license.
    expires_at = resource2.Body('expires_at')
    #: license_type of the license
    license_type = resource2.Body('license_type')

    def create(self, session, l_type):
        url = self.base_path
        resp = session.post(url,
                            endpoint_filter=self.service,
                            json={"license_type": l_type})
        self._translate_response(resp, has_body=True)
        return self
Beispiel #7
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 #8
0
    def test_create(self):
        location = "location"
        mapping = {"first_name": "first-name"}

        sot = resource2.QueryParameters(location, **mapping)

        self.assertEqual({"location": "location", "first_name": "first-name"},
                         sot._mapping)
Beispiel #9
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 #10
0
    def test_transpose_not_in_query(self):
        location = "location"
        mapping = {"first_name": "first-name"}

        sot = resource2.QueryParameters(location, **mapping)
        result = sot._transpose({"location": "Brooklyn"})

        # first_name not being in the query shouldn't affect results
        self.assertEqual({"location": "Brooklyn"},
                         result)
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')
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 #13
0
    def test_transpose_unmapped(self):
        location = "location"
        mapping = {"first_name": "first-name"}

        sot = resource2.QueryParameters(location, **mapping)
        result = sot._transpose({"location": "Brooklyn",
                                 "first_name": "Brian",
                                 "last_name": "Curtin"})

        # last_name isn't mapped and shouldn't be included
        self.assertEqual({"location": "Brooklyn", "first-name": "Brian"},
                         result)
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 Server(resource2.Resource):
    resources_key = "servers"
    resource_key = "server"
    base_path = '/servers'
    service = dedicated_hypervisor_service.DedicatedHypervisorService()

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

    _query_mapping = resource2.QueryParameters("image", "flavor", "name",
                                               "status",
                                               changes_since="changes-since")

    # Properties
    #: id of Dedicated Hypervisor instance.
    id = resource2.Body('id')
    #: Link of the Dedicated Hypervisor server.
    links = resource2.Body('links')
    #: name of Dedicated Hypervisor instance.
    name = resource2.Body('name')
    #: description of Dedicated Hypervisor instance.
    description = resource2.Body('description')
    #: type of hypervisor. vsphere_esxi or hyper_v.
    hypervisor_type = resource2.Body('hypervisor_type')
    #: image id of Dedicated Hypervisor instance.
    imageRef = resource2.Body('imageRef')
    image = resource2.Body('imageRef')
    #: flavor id of Dedicated Hypervisor instance.
    flavorRef = resource2.Body('flavorRef')
    flavor = resource2.Body('flavorRef')
    #: Networks.
    networks = resource2.Body('networks')
    #: Password for the administrator.
    adminPass = resource2.Body('adminPass')
    admin_pass = resource2.Body('adminPass')
    #: Status of the Dedicated Hypervisor instance.
    status = resource2.Body('status')
    #: detail of baremetal server.
    baremetal_server = resource2.Body('baremetal_server')
    #: Server's availability zone.
    availability_zone = resource2.Body('availability_zone')
Beispiel #16
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 #17
0
class Image(resource2.Resource, metadata.MetadataMixin):
    resource_key = 'image'
    resources_key = 'images'
    base_path = '/images'
    service = compute_service.ComputeService()

    # capabilities
    allow_get = True
    allow_delete = True
    allow_list = True

    _query_mapping = resource2.QueryParameters("server",
                                               "name",
                                               "status",
                                               "type",
                                               min_disk="minDisk",
                                               min_ram="minRam",
                                               changes_since="changes-since")

    # Properties
    #: Links pertaining to this image. This is a list of dictionaries,
    #: each including keys ``href`` and ``rel``, and optionally ``type``.
    links = resource2.Body('links')
    #: The name of this image.
    name = resource2.Body('name')
    #: Timestamp when the image was created.
    created_at = resource2.Body('created')
    #: Metadata pertaining to this image. *Type: dict*
    metadata = resource2.Body('metadata', type=dict)
    #: The mimimum disk size. *Type: int*
    min_disk = resource2.Body('minDisk', type=int)
    #: The minimum RAM size. *Type: int*
    min_ram = resource2.Body('minRam', type=int)
    #: If this image is still building, its progress is represented here.
    #: Once an image is created, progres will be 100. *Type: int*
    progress = resource2.Body('progress', type=int)
    #: The status of this image.
    status = resource2.Body('status')
    #: Timestamp when the image was updated.
    updated_at = resource2.Body('updated')
    #: Size of the image in bytes. *Type: int*
    size = resource2.Body('OS-EXT-IMG-SIZE:size', type=int)
class SecurityDeviceInterface(resource2.Resource):
    resource_key = "device_interface"
    resources_key = "device_interfaces"
    base_path = '/ecl-api/devices/%(server_id)s/interfaces'
    service = security_portal_service.SecurityPortalService()

    _query_mapping = resource2.QueryParameters(
        "tenantid",
        "usertoken",
    )

    # Capabilities
    allow_get = True
    allow_list = True

    # Properties
    #: Port id on Openstack.
    os_port_id = resource2.Body('os_port_id', alternate_id=True)
    #: Port IP address (if available).
    os_ip_address = resource2.Body('os_ip_address')
    #: Port id on the Network-based Security devices (registered in MSA).
    msa_port_id = resource2.Body('msa_port_id')
    #: Port name on Openstack.
    os_port_name = resource2.Body('os_port_name')
    #: Network Id to which Port is associated on Openstack.
    os_network_id = resource2.Body('os_network_id')
    #: Port Status on Openstack.
    os_port_status = resource2.Body('os_port_status')
    #: Port MAC address on Openstack.
    os_mac_address = resource2.Body('os_mac_address')
    #: Subnet Id to which Port is associated on Openstack.
    os_subnet_id = resource2.Body('os_subnet_id')
    #: Server id of Network-based Security devices.
    os_server_id = resource2.Body('os_server_id')

    def get(self, session, port_id):
        uri = '/ecl-api/devices/interface/%s?tenantid=%s&usertoken=%s' \
              % (port_id, session.get_project_id(), session.get_token())
        resp = session.get(uri, endpoint_filter=self.service)
        self._translate_response(resp, has_body=True)
        return self
Beispiel #19
0
class Operation(resource2.Resource):
    resources_key = "operations"
    service = provider_connectivity_service.ProviderConnectivityService("v2.0")
    base_path = '/' + service.version + '/operations'

    # Capabilities
    allow_list = True

    _query_mapping = resource2.QueryParameters("service_type", "resource_type",
                                               "resource_id", "latest")

    # Properties
    #: ID of operation.
    id = resource2.Body('id', alternate_id=True)
    #: Service type.
    service_type = resource2.Body('service_type')
    #: ID of resource.
    resource_id = resource2.Body('resource_id')
    #: Reource type.
    resource_type = resource2.Body('resource_type')
    #: Request type.
    request_type = resource2.Body('request_type')
    #: operation phase.
    phase = resource2.Body('phase')
    #: Status of operation.
    operation_status = resource2.Body('operation_status')
    #: reception datetime. YYYY-MM-DD HH:MM:SS format.
    reception_datetime = resource2.Body('reception_datetime')
    #: commit datetime. YYYY-MM-DD HH:MM:SS format.
    commit_datetime = resource2.Body('commit_datetime')
    #: Request body is stored.
    request_body = resource2.Body('request_body')
    #: Note
    notes = resource2.Body('notes')
    #: Tenant ID
    tenant_id = resource2.Body('tenant_id')
    #: If use this query, the latest operation is returned.
    latest = resource2.Body('latest')
    #: Error
    error = resource2.Body('error')
Beispiel #20
0
class Flavor(resource2.Resource):
    resource_key = 'flavor'
    resources_key = 'flavors'
    base_path = '/flavors'
    service = compute_service.ComputeService()

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

    _query_mapping = resource2.QueryParameters("sort_key",
                                               "sort_dir",
                                               min_disk="minDisk",
                                               min_ram="minRam")

    # Properties
    #: Links pertaining to this flavor. This is a list of dictionaries,
    #: each including keys ``href`` and ``rel``.
    links = resource2.Body('links')
    #: The name of this flavor.
    name = resource2.Body('name')
    #: Size of the disk this flavor offers. *Type: int*
    disk = resource2.Body('disk', type=int)
    #: ``True`` if this is a publicly visible flavor. ``False`` if this is
    #: a private image. *Type: bool*
    is_public = resource2.Body('os-flavor-access:is_public', type=bool)
    #: The amount of RAM (in MB) this flavor offers. *Type: int*
    ram = resource2.Body('ram', type=int)
    #: The number of virtual CPUs this flavor offers. *Type: int*
    vcpus = resource2.Body('vcpus', type=int)
    #: Size of the swap partitions.
    swap = resource2.Body('swap')
    #: Size of the ephemeral data disk attached to this server. *Type: int*
    ephemeral = resource2.Body('OS-FLV-EXT-DATA:ephemeral', type=int)
    #: ``True`` if this flavor is disabled, ``False`` if not. *Type: bool*
    is_disabled = resource2.Body('OS-FLV-DISABLED:disabled', type=bool)
    #: The bandwidth scaling factor this flavor receives on the network.
    rxtx_factor = resource2.Body('rxtx_factor', type=float)
Beispiel #21
0
class Sddc(resource2.Resource):
    resources_key = "sddcs"
    resource_key = "sddc"
    base_path = '/sddcs'
    service = dedicated_hypervisor_service.DedicatedHypervisorService()

    # Capabilities
    allow_list = True
    allow_delete = True

    _query_mapping = resource2.QueryParameters(
        "changes-since",
        "maker",
        "limit",
        "name",
    )

    # Properties
    #: id of sddc instance.
    id = resource2.Body('id')
    #: name of sddc instance.
    name = resource2.Body('name')
Beispiel #22
0
class SecurityDevice(resource2.Resource):
    resource_key = "device"
    resources_key = "devices"
    base_path = '/ecl-api/devices'
    service = security_portal_service.SecurityPortalService()

    _query_mapping = resource2.QueryParameters(
        "tenantid",
        "usertoken",
    )

    # Capabilities
    allow_get = True
    allow_list = True

    # Properties
    #: MSA Device External reference.
    msa_device_id = resource2.Body('msa_device_id', alternate_id=True)
    #: MSA Device Type.
    msa_device_type = resource2.Body('msa_device_type')
    #: Server id of Network-based Security devices.
    os_server_id = resource2.Body('os_server_id')
    #: Server name on Openstack.
    os_server_name = resource2.Body('os_server_name')
    #: Availability zone information.
    os_availability_zone = resource2.Body('os_availability_zone')
    #: Name of admin.
    os_admin_username = resource2.Body('os_admin_username')
    #: Server Status.
    os_server_status = resource2.Body('os_server_status')
    #: Interfaces details associated with the Security Device.
    interfaces = resource2.Body('interfaces')

    def get(self, session, server_id):
        uri = self.base_path + '/%s?tenantid=%s&usertoken=%s' \
              % (server_id, session.get_project_id(), session.get_token())
        resp = session.get(uri, endpoint_filter=self.service)
        self._translate_response(resp, has_body=True)
        return self
Beispiel #23
0
class MCIC(resource2.Resource):
    resource_key = None
    resources_key = None
    base_path = '/mCICs'
    service = connectivity_service.ConnectivityService()

    # capabilities
    allow_get = True
    allow_list = True

    _query_mapping = resource2.QueryParameters("tenant_id", "sort_key",
                                               "sort_dir")

    mcic_id = resource2.Body('mcic_id', alternate_id=True)
    mcic_name = resource2.Body('mcic_name')
    mcic_status = resource2.Body('mcic_status')
    tenant_id = resource2.Body('tenant_id')
    tenant_name = resource2.Body('tenant_name')
    service_type = resource2.Body('service_type')
    ngc = resource2.Body('ngc', dict)
    colo = resource2.Body('colo', dict)
    timezone = resource2.Body('timezone')
Beispiel #24
0
class Datastore(resource2.Resource):
    resource_key = None
    resources_key = 'datastores'
    base_path = '/datastores'
    service = database_service.DatabaseService()

    # capabilities
    allow_list = True

    _query_mapping = resource2.QueryParameters()

    # Properties
    #: The ID of this datastore
    id = resource2.Body('id')
    #: The name of this datastore.
    name = resource2.Body('name')
    #: Size of the disk this datastore offers. *Type: int*
    default_version = resource2.Body('default_version')
    #: The amount of RAM (in MB) this datastore offers. *Type: int*
    versions = resource2.Body('versions')
    #: Links pertaining to this datastore. This is a list of dictionaries,
    #: each including keys ``href`` and ``rel``.
    links = resource2.Body('links')
Beispiel #25
0
class Operation(resource2.Resource):

    resource_key = None
    resources_key = None

    base_path = '/operations'
    service = connectivity_service.ConnectivityService()

    # capabilities
    allow_get = True
    allow_list = True

    _query_mapping = resource2.QueryParameters("mcic_id", "cic_id")

    operation_id = resource2.Body('operation_id', alternate_id=True)
    operation_status = resource2.Body('operation_status')
    operation_type = resource2.Body('operation_type')
    operation_body = resource2.Body('operation_body', dict)
    mcic_id = resource2.Body('mcic_id')
    cic_id = resource2.Body('cic_id')
    user_id = resource2.Body('user_id')
    user_name = resource2.Body('user_name')
    receipt_date = resource2.Body('receipt_date')
    error_messages = resource2.Body('error_messages', list)
class VirtualNetworkAppliancePlan(base.VirtualNetworkApplianceBaseResource):
    resources_key = "virtual_network_appliance_plans"
    resource_key = "virtual_network_appliance_plan"
    service = virtual_network_appliance_service.\
        VirtualNetworkApplianceService("v1.0")
    base_path = '/' + service.version + '/virtual_network_appliance_plans'

    # Capabilities
    allow_list = True
    allow_get = True

    _query_mapping = resource2.QueryParameters("details")

    # Properties
    #: It identifies connection resource uniquely.
    id = resource2.Body('id')
    #: Name of virtual network appliance plan.
    name = resource2.Body('name')
    #: Description of virtual network appliance plan.
    description = resource2.Body('description')
    #: Appliance type of virtual network appliance plan.
    appliance_type = resource2.Body('appliance_type')
    #: Version of virtual network appliance plan.
    version = resource2.Body('version')
    #: Flavor of virtual network appliance plan.
    flavor = resource2.Body('flavor')
    #: Number of interfaces of virtual network appliance plan.
    number_of_interfaces = resource2.Body('number_of_interfaces')
    #: Enable flag of virtual network appliance plan.
    enabled = resource2.Body('enabled')
    #: Max number of allowed address pairs of virtual network appliance plan.
    max_number_of_aap = resource2.Body('max_number_of_aap')
    #: License information of virtual network appliance plan.
    licenses = resource2.Body('licenses')
    #: Available zone/group information of virtual network appliance plan.
    availability_zones = resource2.Body('availability_zones')
Beispiel #27
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 #28
0
class Instance(resource2.Resource):
    resource_key = 'instance'
    resources_key = 'instances'
    base_path = '/instances'
    service = database_service.DatabaseService()

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

    allow_update = False

    _query_mapping = resource2.QueryParameters()

    #: ID of the server
    id = resource2.Body('id')

    #: Timestamp of when the instance was created.
    created_at = resource2.Body('created')

    #: The datastore property returned as instence property.
    datastore = resource2.Body('datastore', type=dict)

    #: The flavor property returned from instance.
    flavor = resource2.Body('flavor', type=dict)

    #: The flavor reference, as a ID or full URL,
    #: in case create instane.
    flavor_id = resource2.Body('flavorRef')

    #: An ID representing the host of this instance.
    hostname = resource2.Body('hostname')

    #: A list of dictionaries holding links relevant to this instance.
    links = resource2.Body('links', type=list)

    #: Name of the instance
    name = resource2.Body('name')

    #: Region of the instance
    region = resource2.Body('region')

    #: The state this instance is in.
    status = resource2.Body('status')

    #: Timestamp of when this instance was last updated.
    updated_at = resource2.Body('updated')

    #: The volume property returned from instance.
    volume = resource2.Body('volume', type=dict)

    #: A nic definition object. Required parameter when there are multiple
    #: networks defined for the tenant.
    nics = resource2.Body('nics', type=dict)

    #: Databases list of instance.
    databases = resource2.Body('databases', type=list)

    #: Users list of instance.
    users = resource2.Body('users', type=list)

    #: Backup window of instance.
    backup_window = resource2.Body('backup_window')

    #: Maintenance window of instance.
    maintenance_window = resource2.Body('maintenance_window')

    #: Backup retension period of this instance.
    backup_retention_period = resource2.Body('backup_retention_period',
                                             type=int)

    #: Restore Point
    restore_point = resource2.Body('restorePoint', type=dict)

    #: Restoreable Time
    restorable_time = resource2.Body('restorable_time')

    #: Endpoints
    endpoints = resource2.Body('endpoints', type=list)

    #: Availability Zone
    availability_zone = resource2.Body('availability_zone')

    @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 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 #30
0
class Snapshot(resource2.Resource):
    resource_key = 'snapshot'
    resources_key = 'snapshots'
    base_path = '/snapshots'

    service = storage_service.StorageService()

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

    # query mappings
    _query_mapping = resource2.QueryParameters('volume_id', )

    # Properties
    #: id of snapshot(UUID)
    id = resource2.Body('id')
    #: status of volume
    status = resource2.Body('status')
    #: Name of volume
    name = resource2.Body('name')
    #: Description of snapshot
    description = resource2.Body('description')
    #: Usage of snapshot
    usage = resource2.Body('usage', type=int)
    #: ID (UUID) of parent volume
    volume_id = resource2.Body('volume_id')
    #: ID (UUID) of snapshot type
    snapshot_type_id = resource2.Body('snapshot_type_id')
    #: Creation timestamp of snapshot
    created_at = resource2.Body('created_at')
    #: Update timestamp of snapshot
    updated_at = resource2.Body('updated_at')
    #: Delete timestamp of snapshot
    deleted_at = resource2.Body('deleted_at')
    #: Error message for snapshot
    error_message = resource2.Body('error_message')
    #: Reason of automatic deletion
    delete_reason = resource2.Body('delete_reason')

    def _action(self, session, body):
        """Preform server actions given the message body."""
        # NOTE: This is using Server.base_path instead of self.base_path
        # as both Server and ServerDetail instances can be acted on, but
        # the URL used is sans any additional /detail/ part.
        url = utils.urljoin(Snapshot.base_path, self.id, 'action')
        headers = {'Accept': ''}
        return session.post(url,
                            endpoint_filter=self.service,
                            json=body,
                            headers=headers)

    def create(self, session, **attrs):
        body = {"snapshot": attrs}
        resp = session.post(self.base_path,
                            endpoint_filter=self.service,
                            json=body,
                            headers={"Accept": "application/json"})
        self._translate_response(resp, has_body=True)
        return self

    def update(self, session, volume_id, has_body=True, **attrs):
        uri = utils.urljoin(self.base_path, volume_id)
        body = {"snapshot": attrs}
        args = {'json': body}
        resp = session.put(uri, endpoint_filter=self.service, **args)
        self._translate_response(resp, has_body)
        return self

    def restore(self, session):
        """Restore volume from specified snapshot"""
        body = {'restore': None}
        self._action(session, body)