2013-03-13 18:09:17 -04:00
|
|
|
# Copyright 2012 OpenStack Foundation
|
2012-03-22 12:23:39 +01:00
|
|
|
# All Rights Reserved.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
# not use this file except in compliance with the License. You may obtain
|
|
|
|
# a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
|
|
|
|
"""Cloudpipe interface."""
|
|
|
|
|
|
|
|
from novaclient import base
|
|
|
|
|
|
|
|
|
|
|
|
class Cloudpipe(base.Resource):
|
2014-09-16 17:40:06 -07:00
|
|
|
"""A cloudpipe instance is a VPN attached to a project's VLAN."""
|
2012-03-22 12:23:39 +01:00
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return "<Cloudpipe: %s>" % self.project_id
|
|
|
|
|
|
|
|
def delete(self):
|
2015-12-25 11:55:05 +09:00
|
|
|
"""
|
|
|
|
Delete the own cloudpipe instance
|
|
|
|
|
|
|
|
:returns: An instance of novaclient.base.TupleWithMeta
|
|
|
|
"""
|
|
|
|
return self.manager.delete(self)
|
2012-03-22 12:23:39 +01:00
|
|
|
|
|
|
|
|
|
|
|
class CloudpipeManager(base.ManagerWithFind):
|
|
|
|
resource_class = Cloudpipe
|
|
|
|
|
|
|
|
def create(self, project):
|
2015-12-07 17:35:19 +09:00
|
|
|
"""Launch a cloudpipe instance.
|
2012-03-22 12:23:39 +01:00
|
|
|
|
2012-07-19 09:47:40 +02:00
|
|
|
:param project: UUID of the project (tenant) for the cloudpipe
|
2012-03-22 12:23:39 +01:00
|
|
|
"""
|
|
|
|
body = {'cloudpipe': {'project_id': project}}
|
|
|
|
return self._create('/os-cloudpipe', body, 'instance_id',
|
2014-09-25 18:13:22 +03:00
|
|
|
return_raw=True)
|
2012-03-22 12:23:39 +01:00
|
|
|
|
|
|
|
def list(self):
|
2015-12-07 17:35:19 +09:00
|
|
|
"""Get a list of cloudpipe instances."""
|
2012-03-22 12:23:39 +01:00
|
|
|
return self._list('/os-cloudpipe', 'cloudpipes')
|
2012-11-26 14:21:35 +10:30
|
|
|
|
|
|
|
def update(self, address, port):
|
2015-12-07 17:35:19 +09:00
|
|
|
"""Configure cloudpipe parameters for the project.
|
|
|
|
|
2012-11-26 14:21:35 +10:30
|
|
|
Update VPN address and port for all networks associated
|
|
|
|
with the project defined by authentication
|
|
|
|
|
|
|
|
:param address: IP address
|
|
|
|
:param port: Port number
|
2015-12-25 11:55:05 +09:00
|
|
|
:returns: An instance of novaclient.base.TupleWithMeta
|
2012-11-26 14:21:35 +10:30
|
|
|
"""
|
|
|
|
|
|
|
|
body = {'configure_project': {'vpn_ip': address,
|
|
|
|
'vpn_port': port}}
|
2015-12-25 11:55:05 +09:00
|
|
|
return self._update("/os-cloudpipe/configure-project", body)
|