summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJerry Flood <jf9860@att.com>2017-11-14 12:20:31 -0500
committerJerry Flood <jf9860@att.com>2017-11-14 12:25:50 -0500
commit95ac50513a104b4ec83f2379f39845942c9e9ed2 (patch)
tree6e030459a54a8bfdf334822bf35e0169cc7a50fd
parent77028213a893086c62044a6eab5fd064e343e83b (diff)
Tenant id and name were swapped
Set project_id rather than project_name Set some defaults. Issue: TEST-71 Change-Id: I852e1d238b1cf09dc918a6df1a60dcc7daea62c7 Signed-off-by: Jerry Flood <jf9860@att.com>
-rw-r--r--heatbridge/heatbridge/AAIManager.py62
-rw-r--r--heatbridge/heatbridge/OpenstackManager.py32
2 files changed, 54 insertions, 40 deletions
diff --git a/heatbridge/heatbridge/AAIManager.py b/heatbridge/heatbridge/AAIManager.py
index 70f974b..06d1553 100644
--- a/heatbridge/heatbridge/AAIManager.py
+++ b/heatbridge/heatbridge/AAIManager.py
@@ -2,10 +2,10 @@ from collections import defaultdict
class AAIManager:
"""AAIManager manages the connection state and interaction between an aai instance and the heatbridge."""
-
+
def __init__(self, context):
self.openstack_context = context;
-
+
def get_link(self, links, link_type):
for link in links:
if link['rel'] == link_type:
@@ -15,19 +15,19 @@ class AAIManager:
transactions = defaultdict(list);
for arg in args:
transactions['transactions'].extend(arg);
- return transactions;
-
+ return transactions;
+
def create_put(self, *args):
put = defaultdict(list);
put['put'].extend(args);
return put;
-
+
def create_vserver_put(self, server_info_dict, volumes_dict):
#setup
put = dict();
body = dict();
put['body'] = body;
-
+
#required fields
put['uri'] = "/cloud-infrastructure/cloud-regions/cloud-region/" + self.openstack_context.owner \
+ "/" + self.openstack_context.region + "/tenants/tenant/" + self.openstack_context.tenant \
@@ -40,14 +40,14 @@ class AAIManager:
#body['in-maint'];
#body['is-closed-loop-disabled'];
#body['resource-version'];
-
+
#optional fields
volumes = []
body['volumes'] = volumes
for volume in volumes_dict:
volumes['volume'] = self.create_volume(volume);
-
- relations = [];
+
+ relations = [];
if self.__exists(server_info_dict['metadata'], 'vnf_id'):
data = self.__create_relationship_data("generic-vnf", "vnf-id", server_info_dict['metadata']['vnf_id']);
list = self.__create_relationship_data_list(data);
@@ -90,22 +90,22 @@ class AAIManager:
relationship_data['relationship-key'] = parent + "." + key;
relationship_data['relationship-value'] = value;
return relationship_data;
-
+
def create_volume(self, volume_dict):
#setup
volume = dict()
volume['volume-id'] = volume_dict['volume']['id']
#volume['volume-selflink']
#volume['resource-version']
- #volume['relationship-list']
+ #volume['relationship-list']
return volume;
-
+
def create_flavor_put(self, flavor_dict):
#setup
put = dict();
body = dict()
put['body'] = body
-
+
#required fields
put['uri'] = "/cloud-infrastructure/cloud-regions/cloud-region/" + self.openstack_context.owner \
+ "/" + self.openstack_context.region + "/flavors/flavor/" + flavor_dict['id']
@@ -123,7 +123,7 @@ class AAIManager:
#body['flavor-disabled']
#body['relationship-list']
return put
-
+
def create_image_put(self, image_dict, server_info):
#setup
put = dict();
@@ -136,28 +136,42 @@ class AAIManager:
body['image-selflink'] = self.get_link(server_info['image']['links'], "bookmark");
if self.__exists(image_dict, 'org.openstack__1__architecture'):
body['image-architecture'] = image_dict['org.openstack__1__architecture']
+ else:
+ body['image-architecture'] = 'unknown'
if self.__exists(image_dict, 'org.openstack__1__os_distro'):
body['image-name'] = image_dict['org.openstack__1__os_distro']
+ else:
+ body['image-name'] = 'unknown'
if self.__exists(image_dict, 'org.openstack__1__os_version'):
body['image-os-version'] = image_dict['org.openstack__1__os_version']
+ else:
+ body['image-os-version'] = 'unknown'
if self.__exists(image_dict, 'org.openstack__1__application_version'):
body['application-version'] = image_dict['org.openstack__1__application_version']
+ else:
+ body['application-version'] = 'unknown'
if self.__exists(image_dict, 'org.openstack__1__application_vendor'):
body['application-vendor'] = image_dict['org.openstack__1__application_vendor']
+ else:
+ body['application-vendor'] = 'unknown'
if self.__exists(image_dict, 'org.openstack__1__application'):
body['application'] = image_dict['org.openstack__1__application']
+ else:
+ body['application'] = 'unknown'
if self.__exists(image_dict, 'os_distro'):
body['image-os-distro'] = image_dict['os_distro']
+ else:
+ body['image-os-distro'] = 'unknown'
#body['metadata']
#body['relationship-list'];
return put
-
+
def __exists(self, the_dict, key):
if key in the_dict and the_dict[key] != "":
return True;
else:
return False;
-
+
def create_l_interface_put(self, port_dict, server_info_dict):
#setup
port = port_dict['port']
@@ -178,17 +192,17 @@ class AAIManager:
for ips in port['fixed_ips']:
if '.' in ips['ip_address']:
v4list.append(self.create_l3_interface_ipv4_address(port, ips));
- if ':' in ips['ip_address']:
+ if ':' in ips['ip_address']:
v6list.append(self.create_l3_interface_ipv6_address(port, ips));
body['network-name'] = port['network_id']
#body['selflink']
#body['interface-role']
#body['v6-wan-link-ip']
#body['management-option']
-
+
#optional fields
return put
-
+
def create_l3_interface_ipv4_address(self, port_dict, fixed_ip):
#setup
address = dict()
@@ -199,9 +213,9 @@ class AAIManager:
#address['vlan-id-inner']
#address['vlan-id-outer']
#address['is-floating']
- #address['relationship-list']
+ #address['relationship-list']
return address;
-
+
def create_l3_interface_ipv6_address(self, port_dict, fixed_ip):
#setup
address = dict()
@@ -212,8 +226,8 @@ class AAIManager:
#address['vlan-id-inner']
#address['vlan-id-outer']
#address['is-floating']
- #address['relationship-list']
+ #address['relationship-list']
return address;
-
+
def load_aai_data(self, request):
- return True; \ No newline at end of file
+ return True;
diff --git a/heatbridge/heatbridge/OpenstackManager.py b/heatbridge/heatbridge/OpenstackManager.py
index ed4cd6f..07eddc7 100644
--- a/heatbridge/heatbridge/OpenstackManager.py
+++ b/heatbridge/heatbridge/OpenstackManager.py
@@ -8,7 +8,7 @@ import logging
class OpenstackManager:
"""OpenstackManager manages the connection state and interaction between an openstack cloud and the heatbridge."""
-
+
#this holds the session of the openstack clients
__heat_client = None;
__nova_client = None;
@@ -20,8 +20,8 @@ class OpenstackManager:
def __init__(self, identity_url, context):
""" OpenstackManager
- `identity_url` Base identity_url of the identity server
- 'context' Instance of OpenstackContext
+ `identity_url` Base identity_url of the identity server
+ 'context' Instance of OpenstackContext
"""
self.openstack_context = context;
self.identity_url = identity_url;
@@ -32,54 +32,54 @@ class OpenstackManager:
""" Authenticate to openstack env
`username` username to authenticate to openstack
-
+
`password` password to send
-
+
`tenant` tenant to authenticate under
-
+
`region` region to authenticate under
"""
self.__heat_client = os_client_config.make_client('orchestration',
auth_url=self.identity_url,
username=username,
password=password,
- project_name=tenant,
+ project_id=tenant,
region_name=region);
self.__nova_client = os_client_config.make_client('compute',
auth_url=self.identity_url,
username=username,
password=password,
- project_name=tenant,
+ project_id=tenant,
region_name=region);
self.__cinder_client = os_client_config.make_client('volume',
auth_url=self.identity_url,
username=username,
password=password,
- project_name=tenant,
+ project_id=tenant,
region_name=region);
self.__glance_client = os_client_config.make_client('image',
auth_url=self.identity_url,
username=username,
password=password,
- project_name=tenant,
+ project_id=tenant,
region_name=region);
self.__neutron_client = os_client_config.make_client('network',
auth_url=self.identity_url,
username=username,
password=password,
- project_name=tenant,
+ project_id=tenant,
region_name=region);
#this next line is needed because for v2 apis that are after a certain release stopped providing version info in keytone url but rackspace did not
self.__neutron_client.action_prefix = "";
self.__auth_resp = True;
-
+
def get_stack(self, stack_id):
self.__check_authenticated()
#: :type client: HeatClient
client = self.__heat_client
stack = client.stacks.get(stack_id)
return stack.to_dict();
-
+
def get_stack_resources(self, stack_id):
self.__check_authenticated()
#: :type client: HeatClient
@@ -87,7 +87,7 @@ class OpenstackManager:
stack_resources = client.resources.list(stack_id);
stack_resources_dict = map(lambda x:x.to_dict(),stack_resources)
return stack_resources_dict;
-
+
def get_server_volumes(self, server_id):
self.__check_authenticated()
#: :type client: NovaClient
@@ -95,7 +95,7 @@ class OpenstackManager:
server_volumes = client.volumes.get_server_volumes(server_id);
server_volumes_dict = map(lambda x:x.to_dict(),server_volumes)
return server_volumes_dict;
-
+
def get_server_interfaces(self, server_id):
self.__check_authenticated()
#: :type client: NovaClient
@@ -138,7 +138,7 @@ class OpenstackManager:
client = self.__neutron_client;
port_info = client.show_port(port_id);
return port_info;
-
+
def __check_authenticated(self):
if self.__auth_resp == None:
raise AssertionError('__auth_resp should exist before calling operation') \ No newline at end of file