Ejemplo n.º 1
0
    def connect(self, access, authentication_data, region):
        '''
        TBD
        '''

        try:
            _status = 100
            _fmsg = "An error has occurred, but no error message was captured"

            _username, _api_key, _api_type = authentication_data.split('-')
            if access.lower().count("private"):
                self.slconn = SoftLayer.create_client_from_env (username = _username.strip(), \
                                                                api_key= _api_key.strip(), \
                                                                endpoint_url = SoftLayer.API_PRIVATE_ENDPOINT)
            else:
                self.slconn = SoftLayer.create_client_from_env (username = _username.strip(), \
                                                                api_key= _api_key.strip(), \
                                                                endpoint_url = SoftLayer.API_PUBLIC_ENDPOINT)

            _resp = self.slconn.call('Account', 'getObject')

            _datacenters = SoftLayer.VSManager(
                self.slconn).get_create_options()['datacenters']
            for _dcitem in _datacenters:
                if region == _dcitem['template']['datacenter']['name']:
                    _region = _dcitem['template']['datacenter']['name']

            _msg = "Selected region is " + str(region) + " (" + _region + ")"

            if _api_type.lower().count("baremetal"):
                self.nodeman = SoftLayer.HardwareManager(self.slconn)
            else:
                self.nodeman = SoftLayer.VSManager(self.slconn)

            self.sshman = SoftLayer.SshKeyManager(self.slconn)

            self.imageman = SoftLayer.ImageManager(self.slconn)

            _status = 0

        except Exception as msg:
            _fmsg = str(msg)
            _status = 23

        finally:
            if _status:
                _msg = self.get_description() + " connection failure: " + _fmsg
                cberr(_msg)
                raise CldOpsException(_msg, _status)
            else:

                _msg = self.get_description() + " connection successful."
                cbdebug(_msg)
                return _status, _msg, _region
Ejemplo n.º 2
0
def manual_provision_vms(vs_config,
                         groupname,
                         groupdef,
                         clustername,
                         score,
                         client,
                         sl_storage,
                         configuration,
                         containername):
    configs = []
    count = int(groupdef['count'])
    for i in range(count):
        vscopy = vs_config.copy()
        vscopy['hostname'] = vscopy['hostname']+'-'+str(i)
        configs.append(vscopy)
    lib.debug(json.dumps(configs, indent=4, sort_keys=True))

    vs_manager = SoftLayer.VSManager(client)

    vms = lib.sl_retry(vs_manager.create_instances, configs)

    for vm in vms:
        lib.save_state(sl_storage, containername,
                       "serverinstances/{}/vms/{}/id".format(
                            groupname, vm['hostname']),
                       vm['id'])

    for vm in vms:
        lib.sl_retry(vs_manager.wait_for_ready, vm['id'], 600)

    groupdef['vms'] = []
    for vm in vms:
        groupdef['vms'].append(vs_manager.get_instance(vm['id']))
Ejemplo n.º 3
0
    def on_get(self, req, resp, tenant_id):
        client = req.sl_client
        vs = SoftLayer.VSManager(client)

        params = get_list_params(req)

        sl_instances = vs.list_instances(**params)
        if not isinstance(sl_instances, list):
            sl_instances = [sl_instances]

        results = []
        for instance in sl_instances:
            id = str(instance['id'])
            results.append({
                'id':
                id,
                'links': [{
                    'href':
                    self.app.get_endpoint_url('compute',
                                              req,
                                              'v2_server',
                                              server_id=id),
                    'rel':
                    'self',
                }],
                'name':
                instance['hostname'],
            })

        resp.status = 200
        resp.body = {'servers': results}
Ejemplo n.º 4
0
def cli(env, **args):
    """Order/create virtual servers."""

    vsi = SoftLayer.VSManager(env.client)
    _validate_args(env, args)
    create_args = _parse_create_args(env.client, args)
    test = args.get('test', False)
    do_create = not (args.get('export') or test)

    if do_create:
        if not (env.skip_confirmations or formatting.confirm(
                "This action will incur charges on your account. Continue?")):
            raise exceptions.CLIAbort('Aborting virtual server order.')

    if args.get('export'):
        export_file = args.pop('export')
        template.export_to_template(export_file, args, exclude=['wait', 'test'])
        env.fout('Successfully exported options to a template file.')

    else:
        result = vsi.order_guest(create_args, test)
        output = _build_receipt_table(result, args.get('billing'), test)

        if do_create:
            env.fout(_build_guest_table(result))
        env.fout(output)

        if args.get('wait'):
            virtual_guests = utils.lookup(result, 'orderDetails', 'virtualGuests')
            guest_id = virtual_guests[0]['id']
            click.secho("Waiting for %s to finish provisioning..." % guest_id, fg='green')
            ready = vsi.wait_for_ready(guest_id, args.get('wait') or 1)
            if ready is False:
                env.out(env.fmt(output))
                raise exceptions.CLIHalt(code=1)
Ejemplo n.º 5
0
    def execute(self, args):
        vsi = SoftLayer.VSManager(self.client)

        vs_id = helpers.resolve_id(vsi.resolve_ids,
                                   args.get('<identifier>'),
                                   'VS')

        if args['--all']:
            additional_disks = True
        else:
            additional_disks = False

        capture = vsi.capture(vs_id,
                              args.get('--name'),
                              additional_disks,
                              args.get('--note'))

        table = formatting.KeyValueTable(['Name', 'Value'])
        table.align['Name'] = 'r'
        table.align['Value'] = 'l'

        table.add_row(['vs_id', capture['guestId']])
        table.add_row(['date', capture['createDate'][:10]])
        table.add_row(['time', capture['createDate'][11:19]])
        table.add_row(['transaction', formatting.transaction_status(capture)])
        table.add_row(['transaction_id', capture['id']])
        table.add_row(['all_disks', additional_disks])
        return table
Ejemplo n.º 6
0
def cli(env, identifier):
    """Get billing for a virtual device."""
    virtual = SoftLayer.VSManager(env.client)

    virtual_id = helpers.resolve_id(virtual.resolve_ids, identifier, 'virtual')
    result = virtual.get_instance(virtual_id)
    table = formatting.KeyValueTable(['name', 'value'])
    table.align['name'] = 'r'
    table.align['value'] = 'l'

    table.add_row(['Id', identifier])

    table.add_row(
        ['Billing Item Id',
         utils.lookup(result, 'billingItem', 'id')])
    table.add_row(
        ['Recurring Fee',
         utils.lookup(result, 'billingItem', 'recurringFee')])
    table.add_row([
        'Total',
        utils.lookup(result, 'billingItem', 'nextInvoiceTotalRecurringAmount')
    ])
    table.add_row(['Provision Date', utils.lookup(result, 'provisionDate')])

    price_table = formatting.Table(['Description', 'Recurring Price'])
    for item in utils.lookup(result, 'billingItem', 'children') or []:
        price_table.add_row(
            [item['description'], item['nextInvoiceTotalRecurringAmount']])

    table.add_row(['prices', price_table])
    env.fout(table)
Ejemplo n.º 7
0
def main(dict):

    API_USERNAME = dict['user']
    API_KEY = dict['apikey']
    VSI = dict['vsi']
    client = SoftLayer.create_client_from_env(username=API_USERNAME, api_key=API_KEY)
    mgr = SoftLayer.VSManager(client)
    imageName = VSI + '_' + datetime.datetime.today().isoformat()

    try:
        virtualGuests = client['SoftLayer_Account'].getVirtualGuests()

    except SoftLayer.SoftLayerAPIError as e:
        print("Unable to retrieve virtual guest. "
              % (e.faultCode, e.faultString))

    vsiFound = False
    res = "ERROR"
    virtualMachines = 'None'
    for virtualGuest in virtualGuests:
        if virtualGuest['hostname'] == VSI:
            vsiFound = True
            try:
                res = mgr.capture(instance_id=virtualGuest['id'], name=imageName, notes=API_USERNAME)
                print ("VSI", VSI, "is found. Now capturing an image template:", imageName)

            except SoftLayer.SoftLayerAPIError as e:
                 vsiFound = e

    return { 'VSI' : VSI, 'ImageName' : imageName, 'Action_Performed' : vsiFound, 'result' : res }
Ejemplo n.º 8
0
def cli(env, vsi_type, prices, location=None):
    """Virtual server order options."""

    vsi = SoftLayer.VSManager(env.client)
    options = vsi.get_create_options(vsi_type, location)

    tables = []

    # Datacenters
    dc_table = formatting.Table(['datacenter', 'Value'], title="Datacenters")
    dc_table.sortby = 'Value'
    dc_table.align = 'l'
    for location_info in options['locations']:
        dc_table.add_row([location_info['name'], location_info['key']])
    tables.append(dc_table)

    if vsi_type == 'CLOUD_SERVER':
        tables.append(guest_core_prices_table(options['guest_core'], prices))
        tables.append(ram_prices_table(options['ram'], prices))
    else:
        tables.append(preset_prices_table(options['sizes'], prices))
    tables.append(os_prices_table(options['operating_systems'], prices))
    tables.append(port_speed_prices_table(options['port_speed'], prices))
    tables.append(database_prices_table(options['database'], prices))
    tables.append(guest_disk_prices_table(options['guest_disk'], prices))
    tables.append(extras_prices_table(options['extras'], prices))

    env.fout(tables)
Ejemplo n.º 9
0
 def execute(self, args):
     virtual_guest = self.client['Virtual_Guest']
     vsi = SoftLayer.VSManager(self.client)
     vs_id = helpers.resolve_id(vsi.resolve_ids,
                                args.get('<identifier>'),
                                'VS')
     virtual_guest.resume(id=vs_id)
def main(params):
    try:
        if len(params) < 4:
            print("insufficient parameters!")
        else:
            sl_user = str(params[0])
            sl_apikey = str(params[1])
            instance_id = int(params[2])
            image_name = str(params[3])

            client = SoftLayer.create_client_from_env(username=sl_user,
                                                      api_key=sl_apikey)

            # check if image with image_name exist or not
            # if exist, remove it
            imageManager = SoftLayer.ImageManager(client)
            image_list = imageManager.list_private_images(name=image_name)
            for image in image_list:
                info = imageManager.get_image(image['id'])
                print("found image with " + image_name + ", delete it")
                print(info)
                info = imageManager.delete_image(image['id'])

            # create transaction to capture the image
            vsManager = SoftLayer.VSManager(client)
            image_info = vsManager.capture(instance_id, image_name)
            print(image_info)

    except Exception:
        print(traceback.format_exc())
Ejemplo n.º 11
0
def cli(env, identifier, cpu, private, memory, network, flavor, add_disk, resize_disk):
    """Upgrade a virtual server."""

    vsi = SoftLayer.VSManager(env.client)

    if not any([cpu, memory, network, flavor, resize_disk, add_disk]):
        raise exceptions.ArgumentError("Must provide [--cpu],"
                                       " [--memory], [--network], [--flavor], [--resize-disk], or [--add] to upgrade")

    if private and not cpu:
        raise exceptions.ArgumentError("Must specify [--cpu] when using [--private]")

    vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS')
    if not (env.skip_confirmations or formatting.confirm("This action will incur charges on your account. Continue?")):
        raise exceptions.CLIAbort('Aborted')

    disk_json = []
    if memory:
        memory = int(memory / 1024)
    if resize_disk:
        for guest_disk in resize_disk:
            disks = {'capacity': guest_disk[0], 'number': guest_disk[1]}
            disk_json.append(disks)

    elif add_disk:
        for guest_disk in add_disk:
            disks = {'capacity': guest_disk, 'number': -1}
            disk_json.append(disks)

    if not vsi.upgrade(vs_id, cpus=cpu, memory=memory, nic_speed=network, public=not private, preset=flavor,
                       disk=disk_json):
        raise exceptions.CLIAbort('VS Upgrade Failed')
Ejemplo n.º 12
0
def main(dict):

    API_USERNAME = dict['user']
    API_KEY = dict['apikey']
    VSI = dict['vsi']

    client = SoftLayer.create_client_from_env(username=API_USERNAME,
                                              api_key=API_KEY)
    mgr = SoftLayer.VSManager(client)
    mgr_image = SoftLayer.ImageManager(client)

    vsiname = VSI
    image_list = mgr_image.list_private_images(name=vsiname + '_*')
    image_list.sort(key=lambda x: x['createDate'])

    number_of_snapshots = len(image_list)
    #  print('*** Before deleting old image templates')
    #      for i in range(0, number_of_snapshots):
    #           print(image_list[i]['id'], image_list[i]['createDate'],  image_list[i]['name'] )

    deleted_image = []
    if number_of_snapshots > 2:
        for i in range(0, number_of_snapshots - 2):
            #           print(i, image_list[i]['id'], image_list[i]['createDate'],  image_list[i]['name'] )
            deleted_image.append(image_list[i]['name'])
            mgr_image.delete_image(image_list[i]['id'])

    return {'VSI': VSI, 'deleted_image': deleted_image}
Ejemplo n.º 13
0
def cli(env, title, subject_id, body, hardware_identifier, virtual_identifier,
        priority):
    """Create a support ticket."""
    ticket_mgr = SoftLayer.TicketManager(env.client)

    if body is None:
        body = click.edit('\n\n' + ticket.TEMPLATE_MSG)
    created_ticket = ticket_mgr.create_ticket(title=title,
                                              body=body,
                                              subject=subject_id,
                                              priority=priority)

    if hardware_identifier:
        hardware_mgr = SoftLayer.HardwareManager(env.client)
        hardware_id = helpers.resolve_id(hardware_mgr.resolve_ids,
                                         hardware_identifier, 'hardware')
        ticket_mgr.attach_hardware(created_ticket['id'], hardware_id)

    if virtual_identifier:
        vs_mgr = SoftLayer.VSManager(env.client)
        vs_id = helpers.resolve_id(vs_mgr.resolve_ids, virtual_identifier,
                                   'VS')
        ticket_mgr.attach_virtual_server(created_ticket['id'], vs_id)

    env.fout(ticket.get_ticket_results(ticket_mgr, False,
                                       created_ticket['id']))
Ejemplo n.º 14
0
def cli(env, identifier, cpu, private, memory, network, flavor):
    """Upgrade a virtual server."""

    vsi = SoftLayer.VSManager(env.client)

    if not any([cpu, memory, network, flavor]):
        raise exceptions.ArgumentError(
            "Must provide [--cpu], [--memory], [--network], or [--flavor] to upgrade")

    if private and not cpu:
        raise exceptions.ArgumentError(
            "Must specify [--cpu] when using [--private]")

    vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS')
    if not (env.skip_confirmations or formatting.confirm(
            "This action will incur charges on your account. "
            "Continue?")):
        raise exceptions.CLIAbort('Aborted')

    if memory:
        memory = int(memory / 1024)

    if not vsi.upgrade(vs_id,
                       cpus=cpu,
                       memory=memory,
                       nic_speed=network,
                       public=not private,
                       preset=flavor):
        raise exceptions.CLIAbort('VS Upgrade Failed')
Ejemplo n.º 15
0
    def execute(self, args):
        data = {}

        if args['--userdata'] and args['--userfile']:
            raise exceptions.ArgumentError(
                '[-u | --userdata] not allowed with [-F | --userfile]')
        if args['--userfile']:
            if not os.path.exists(args['--userfile']):
                raise exceptions.ArgumentError(
                    'File does not exist [-u | --userfile] = %s'
                    % args['--userfile'])

        if args.get('--userdata'):
            data['userdata'] = args['--userdata']
        elif args.get('--userfile'):
            with open(args['--userfile'], 'r') as userfile:
                data['userdata'] = userfile.read()

        data['hostname'] = args.get('--hostname')
        data['domain'] = args.get('--domain')
        data['tag'] = args.get("--tag")

        vsi = SoftLayer.VSManager(self.client)
        vs_id = helpers.resolve_id(vsi.resolve_ids,
                                   args.get('<identifier>'),
                                   'VS')
        if not vsi.edit(vs_id, **data):
            raise exceptions.CLIAbort("Failed to update virtual server")
Ejemplo n.º 16
0
def cli(env, identifier, domain, userfile, tag, hostname, userdata):
    """Edit a virtual server's details."""

    data = {}

    if userdata and userfile:
        raise exceptions.ArgumentError(
            '[-u | --userdata] not allowed with [-F | --userfile]')
    if userfile:
        if not os.path.exists(userfile):
            raise exceptions.ArgumentError(
                'File does not exist [-u | --userfile] = %s' % userfile)

    if userdata:
        data['userdata'] = userdata
    elif userfile:
        with open(userfile, 'r') as userfile_obj:
            data['userdata'] = userfile_obj.read()

    data['hostname'] = hostname
    data['domain'] = domain
    data['tag'] = tag

    vsi = SoftLayer.VSManager(env.client)
    vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS')
    if not vsi.edit(vs_id, **data):
        raise exceptions.CLIAbort("Failed to update virtual server")
Ejemplo n.º 17
0
def cli(env, identifier):
    """Get details for a vsi monitors device."""

    vsi = SoftLayer.VSManager(env.client)

    table = formatting.KeyValueTable(['name', 'value'])
    table.align['name'] = 'r'
    table.align['value'] = 'l'

    monitoring = vsi.get_instance(identifier)

    table.add_row(['Domain', monitoring.get('fullyQualifiedDomainName')])
    table.add_row(['Public Ip', monitoring.get('primaryIpAddress')])
    table.add_row(['Private Ip', monitoring.get('primaryBackendIpAddress')])
    table.add_row(['Location', monitoring['datacenter']['longName']])

    monitoring_table = formatting.Table(
        ['Id', 'IpAddress', 'Status', 'Type', 'Notify'])
    for monitor in monitoring['networkMonitors']:
        monitoring_table.add_row([
            monitor.get('id'),
            monitor.get('ipAddress'),
            monitor.get('status'), monitor['queryType']['name'],
            monitor['responseAction']['actionDescription']
        ])

    table.add_row(['Devices monitors', monitoring_table])

    env.fout(table)
Ejemplo n.º 18
0
def cli(env, sortby, cpu, domain, datacenter, hostname, memory, network,
        hourly, monthly, tag, columns, limit, transient):
    """List virtual servers."""

    vsi = SoftLayer.VSManager(env.client)
    guests = vsi.list_instances(hourly=hourly,
                                monthly=monthly,
                                hostname=hostname,
                                domain=domain,
                                cpus=cpu,
                                memory=memory,
                                datacenter=datacenter,
                                nic_speed=network,
                                transient=transient,
                                tags=tag,
                                mask=columns.mask(),
                                limit=limit)

    table = formatting.Table(columns.columns)
    table.sortby = sortby
    for guest in guests:
        table.add_row(
            [value or formatting.blank() for value in columns.row(guest)])

    env.fout(table)
Ejemplo n.º 19
0
    def get_virtual_servers(self):
        '''Get all the CCI instances'''
        vs = SoftLayer.VSManager(self.client)
        instances = vs.list_instances()

        for instance in instances:
            self.process_instance(instance)
Ejemplo n.º 20
0
def cli(env, identifier, domain, userfile, tag, hostname, userdata,
        public_speed, private_speed):
    """Edit a virtual server's details."""

    if userdata and userfile:
        raise exceptions.ArgumentError(
            '[-u | --userdata] not allowed with [-F | --userfile]')

    data = {}

    if userdata:
        data['userdata'] = userdata
    elif userfile:
        with open(userfile, 'r') as userfile_obj:
            data['userdata'] = userfile_obj.read()

    data['hostname'] = hostname
    data['domain'] = domain

    if tag:
        data['tags'] = ','.join(tag)

    vsi = SoftLayer.VSManager(env.client)
    vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS')
    if not vsi.edit(vs_id, **data):
        raise exceptions.CLIAbort("Failed to update virtual server")

    if public_speed is not None:
        vsi.change_port_speed(vs_id, True, int(public_speed))

    if private_speed is not None:
        vsi.change_port_speed(vs_id, False, int(private_speed))
Ejemplo n.º 21
0
    def execute(self, args):
        public = args['public']

        vsi = SoftLayer.VSManager(self.client)
        vs_id = helpers.resolve_id(vsi.resolve_ids, args.get('<identifier>'),
                                   'VS')

        vsi.change_port_speed(vs_id, public, args['--speed'])
Ejemplo n.º 22
0
 def execute(self, args):
     vsi = SoftLayer.VSManager(self.client)
     vs_id = helpers.resolve_id(vsi.resolve_ids, args.get('<identifier>'),
                                'VS')
     if args['--really'] or formatting.no_going_back(vs_id):
         vsi.cancel_instance(vs_id)
     else:
         raise exceptions.CLIAbort('Aborted')
Ejemplo n.º 23
0
    def get_virtual_servers(self):
        '''Get all the CCI instances'''
        vs = SoftLayer.VSManager(self.client)
        mask = "mask[%s]" % ','.join(itertools.chain(self.common_items, self.vs_items))
        instances = vs.list_instances(mask=mask)

        for instance in instances:
            self.process_instance(instance)
Ejemplo n.º 24
0
    def on_get(self, req, resp, tenant_id, server_id):
        client = req.sl_client
        vs = SoftLayer.VSManager(client)

        instance = vs.get_instance(server_id, mask=get_virtual_guest_mask())

        results = get_server_details_dict(self.app, req, instance, True)

        resp.body = {'server': results}
Ejemplo n.º 25
0
def cli(env, identifier, network_type, speed):
    """Manage network settings."""

    public = (network_type == 'public')

    vsi = SoftLayer.VSManager(env.client)
    vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS')

    vsi.change_port_speed(vs_id, public, speed)
Ejemplo n.º 26
0
def cli(env, identifier):
    """Cancel virtual servers."""

    vsi = SoftLayer.VSManager(env.client)
    vs_id = helpers.resolve_id(vsi.resolve_ids, identifier, 'VS')
    if not (env.skip_confirmations or formatting.no_going_back(vs_id)):
        raise exceptions.CLIAbort('Aborted')

    vsi.cancel_instance(vs_id)
Ejemplo n.º 27
0
 def __init__(self, client, id, imageName, hostname, domain, hasRecovery):
     self.client = client
     self.mgr = SoftLayer.VSManager(self.client)
     self.img_mgr = SoftLayer.ImageManager(self.client)
     self.id = id
     self.imageName = imageName
     self.hostname = hostname  #hostname and domain for the temp servers
     self.domain = domain
     self.hasRecovery = hasRecovery
Ejemplo n.º 28
0
 def __init__(self, swift_username, swift_auth_url=default_swift_url):
     self.conf = config.get_client_settings_config_file()
     self.swift_username = swift_username
     self.sl_client = sl.create_client_from_env()
     self.images = sl.ImageManager(self.sl_client)
     self.servers = sl.VSManager(self.sl_client)
     self.swift = client.Connection(authurl=swift_auth_url,
                                    user=swift_username,
                                    key=self.conf['api_key'])
Ejemplo n.º 29
0
def cli(env, identifier):
    """List virtual server credentials."""

    vsi = SoftLayer.VSManager(env.client)
    result = vsi.get_instance(identifier)
    table = formatting.Table(['username', 'password'])
    for item in result['operatingSystem']['passwords']:
        table.add_row([item['username'], item['password']])
    return table
Ejemplo n.º 30
0
    def _update_with_like_args(self, args):
        """ Update arguments with options taken from a currently running VS.

        :param VSManager args: A VSManager
        :param dict args: CLI arguments
        """
        if args['--like']:
            vsi = SoftLayer.VSManager(self.client)
            vs_id = helpers.resolve_id(vsi.resolve_ids,
                                       args.pop('--like'),
                                       'VS')
            like_details = vsi.get_instance(vs_id)
            like_args = {
                '--hostname': like_details['hostname'],
                '--domain': like_details['domain'],
                '--cpu': like_details['maxCpu'],
                '--memory': like_details['maxMemory'],
                '--hourly': like_details['hourlyBillingFlag'],
                '--monthly': not like_details['hourlyBillingFlag'],
                '--datacenter': like_details['datacenter']['name'],
                '--network': like_details['networkComponents'][0]['maxSpeed'],
                '--user-data': like_details['userData'] or None,
                '--postinstall': like_details.get('postInstallScriptUri'),
                '--dedicated': like_details['dedicatedAccountHostOnlyFlag'],
                '--private': like_details['privateNetworkOnlyFlag'],
            }

            tag_refs = like_details.get('tagReferences', None)
            if tag_refs is not None and len(tag_refs) > 0:
                tags = ','.join([t['tag']['name'] for t in tag_refs])
                like_args['--tag'] = tags

            # Handle mutually exclusive options
            like_image = utils.lookup(like_details,
                                      'blockDeviceTemplateGroup',
                                      'globalIdentifier')
            like_os = utils.lookup(like_details,
                                   'operatingSystem',
                                   'softwareLicense',
                                   'softwareDescription',
                                   'referenceCode')
            if like_image and not args.get('--os'):
                like_args['--image'] = like_image
            elif like_os and not args.get('--image'):
                like_args['--os'] = like_os

            if args.get('--hourly'):
                like_args['--monthly'] = False

            if args.get('--monthly'):
                like_args['--hourly'] = False

            # Merge like VS options with the options passed in
            for key, value in like_args.items():
                if args.get(key) in [None, False]:
                    args[key] = value