diff options
author | spisarski <s.pisarski@cablelabs.com> | 2017-08-17 15:21:37 -0600 |
---|---|---|
committer | Steven Pisarski <s.pisarski@cablelabs.com> | 2017-08-24 21:12:02 +0000 |
commit | 1342eb17df248ec75cc57e9c380a7753fc432194 (patch) | |
tree | 72a3b065394b7bcaaddb801e3321edc1ba4b8818 /snaps/domain/vm_inst.py | |
parent | 49aaa5d61e87e11c5d5b9ce7dd2fa598f16b82a7 (diff) |
Added method to return OpenStackVmInstance from Heat.
OpenStackHeatStack now can introspect the VMs that the template
was responsible for deploying and return an instanitated instance
of OpenStackVmInstance for each VM deployed. When the VM has a
Floating IP, these instances have the ability to connect via
SSH just like one created from scratch.
JIRA: SNAPS-172
Change-Id: I5a7ed3a09bb871afc55c718aa80a9069b1eb4da7
Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/domain/vm_inst.py')
-rw-r--r-- | snaps/domain/vm_inst.py | 47 |
1 files changed, 40 insertions, 7 deletions
diff --git a/snaps/domain/vm_inst.py b/snaps/domain/vm_inst.py index ae01cf0..ca38143 100644 --- a/snaps/domain/vm_inst.py +++ b/snaps/domain/vm_inst.py @@ -19,17 +19,35 @@ class VmInst: SNAPS domain object for Images. Should contain attributes that are shared amongst cloud providers """ - def __init__(self, name, inst_id, networks): + def __init__(self, name, inst_id, image_id, flavor_id, networks, + keypair_name, sec_grp_names): """ Constructor :param name: the image's name :param inst_id: the instance's id - :param networks: dict of networks where the key is the subnet name and + :param image_id: the instance's image id + :param flavor_id: the ID used to spawn this instance + :param networks: dict of networks where the key is the network name and value is a list of associated IPs + :param keypair_name: the name of the associated keypair + :param sec_grp_names: list of security group names """ self.name = name self.id = inst_id + self.image_id = image_id + self.flavor_id = flavor_id self.networks = networks + self.keypair_name = keypair_name + self.sec_grp_names = sec_grp_names + + def __eq__(self, other): + return (self.name == other.name and + self.id == other.id and + self.image_id == other.image_id and + self.flavor_id == other.flavor_id and + self.networks == other.networks and + self.keypair_name == other.keypair_name and + self.sec_grp_names == other.sec_grp_names) class FloatingIp: @@ -37,11 +55,26 @@ class FloatingIp: SNAPS domain object for Images. Should contain attributes that are shared amongst cloud providers """ - def __init__(self, inst_id, ip): + def __init__(self, **kwargs): """ Constructor - :param inst_id: the floating ip's id - :param ip: the IP address + :param id: the floating ip's id + :param description: the description + :param ip|floating_ip_address: the Floating IP address mapped to the + 'ip' attribute + :param fixed_ip_address: the IP address of the tenant network + :param floating_network_id: the ID of the external network + :param port_id: the ID of the associated port + :param router_id: the ID of the associated router + :param project_id|tenant_id: the ID of the associated project mapped to + the attribute 'project_id' + :param """ - self.id = inst_id - self.ip = ip + self.id = kwargs.get('id') + self.description = kwargs.get('description') + self.ip = kwargs.get('ip', kwargs.get('floating_ip_address')) + self.fixed_ip_address = kwargs.get('fixed_ip_address') + self.floating_network_id = kwargs.get('floating_network_id') + self.port_id = kwargs.get('port_id') + self.router_id = kwargs.get('router_id') + self.project_id = kwargs.get('project_id', kwargs.get('tenant_id')) |