Skip to content
Snippets Groups Projects
Commit 3ce556c5 authored by Maarten de Waard's avatar Maarten de Waard :angel:
Browse files

Merge branch '317-add-option-to-create-oas-on-non-greenhost-vps' into 'master'

Resolve "Add option to `create` OAS on non-greenhost VPS"

Closes #317

See merge request openappstack/openappstack!89
parents e359f917 a5993b7f
No related branches found
No related tags found
No related merge requests found
...@@ -64,6 +64,11 @@ def main(): # pylint: disable=too-many-statements,too-many-branches,too-many-lo ...@@ -64,6 +64,11 @@ def main(): # pylint: disable=too-many-statements,too-many-branches,too-many-lo
'domain', 'domain',
metavar='DOMAIN_NAME', metavar='DOMAIN_NAME',
help='Domain name to run OpenAppStack under') help='Domain name to run OpenAppStack under')
create_parser.add_argument(
'--hostname',
type=str,
help='hostname of the machine. If not provided for a new machine, a '
'hostname is generated.')
group = create_parser.add_mutually_exclusive_group(required=True) group = create_parser.add_mutually_exclusive_group(required=True)
...@@ -76,14 +81,15 @@ def main(): # pylint: disable=too-many-statements,too-many-branches,too-many-lo ...@@ -76,14 +81,15 @@ def main(): # pylint: disable=too-many-statements,too-many-branches,too-many-lo
metavar='ID', metavar='ID',
type=int, type=int,
help='ID of existing Greenhost VPS to use') help='ID of existing Greenhost VPS to use')
group.add_argument(
'--ip-address',
metavar='IP',
help='IP address of non-greenhost VPS to use. You *must* provide '
'--hostname with this argument')
droplet_creation_group = create_parser.add_argument_group( droplet_creation_group = create_parser.add_argument_group(
'droplet creation', 'droplet creation',
'When using --create-droplet, you need to provide:') 'When using --create-droplet, you need to provide:')
droplet_creation_group.add_argument(
'--hostname',
type=str,
help='hostname of the new machine. If not provided, a hostname is generated')
droplet_creation_group.add_argument( droplet_creation_group.add_argument(
'--ssh-key-id', '--ssh-key-id',
...@@ -239,6 +245,11 @@ def create(clus, args): ...@@ -239,6 +245,11 @@ def create(clus, args):
cosmos.wait_for_ssh(clus.ip_address) cosmos.wait_for_ssh(clus.ip_address)
elif args.droplet_id: elif args.droplet_id:
clus.set_info_by_droplet_id(args.droplet_id) clus.set_info_by_droplet_id(args.droplet_id)
elif args.ip_address:
if not args.hostname:
log.error('--hostname required when using --ip-address')
sys.exit(2)
clus.set_info_by_ip_and_hostname(args.ip_address, args.hostname)
# Write inventory.yml and settings.yml files # Write inventory.yml and settings.yml files
clus.write_cluster_files() clus.write_cluster_files()
......
...@@ -114,6 +114,10 @@ class Cluster: ...@@ -114,6 +114,10 @@ class Cluster:
self.ip_address = droplet['networks']['v4'][0]['ip_address'] self.ip_address = droplet['networks']['v4'][0]['ip_address']
self.hostname = droplet['name'] self.hostname = droplet['name']
def set_info_by_ip_and_hostname(self, ip_address, hostname):
self.ip_address = ip_address
self.hostname = hostname
def write_cluster_files(self): def write_cluster_files(self):
"""Creates an inventory.yml and settings.yml file for the cluster""" """Creates an inventory.yml and settings.yml file for the cluster"""
self.make_cluster_directory() self.make_cluster_directory()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment