def test_equalto_removed(self): args = { '--os': None, '--datacenter': '=ams01', '--memory': '=1g', '--test': '=1344'} argnew = helpers.sanitize_args(args) self.assertEqual(argnew, { '--os': None, '--datacenter': 'ams01', '--memory': '1g', '--test': '1344'})
def _parse_create_args(self, args): """ Converts CLI arguments to arguments that can be passed into VSManager.create_instance. :param dict args: CLI arguments """ args = helpers.sanitize_args(args) data = { "hourly": args['--hourly'], "cpus": args['--cpu'], "domain": args['--domain'], "hostname": args['--hostname'], "private": args['--private'], "dedicated": args['--dedicated'], "disks": args['--disk'], "local_disk": not args['--san'], } try: memory = int(args['--memory']) if memory < 1024: memory = memory * 1024 except ValueError: unit = args['--memory'][-1] memory = int(args['--memory'][0:-1]) if unit in ['G', 'g']: memory = memory * 1024 if unit in ['T', 'r']: memory = memory * 1024 * 1024 data["memory"] = memory if args['--monthly']: data['hourly'] = False if args.get('--os'): data['os_code'] = args['--os'] if args.get('--image'): data['image_id'] = args['--image'] if args.get('--datacenter'): data['datacenter'] = args['--datacenter'] if args.get('--network'): data['nic_speed'] = args.get('--network') if args.get('--userdata'): data['userdata'] = args['--userdata'] elif args.get('--userfile'): with open(args['--userfile'], 'r') as userfile: data['userdata'] = userfile.read() if args.get('--postinstall'): data['post_uri'] = args.get('--postinstall') # Get the SSH keys if args.get('--key'): keys = [] for key in args.get('--key'): resolver = SoftLayer.SshKeyManager(self.client).resolve_ids key_id = helpers.resolve_id(resolver, key, 'SshKey') keys.append(key_id) data['ssh_keys'] = keys if args.get('--vlan_public'): data['public_vlan'] = args['--vlan_public'] if args.get('--vlan_private'): data['private_vlan'] = args['--vlan_private'] if args.get('--tag'): data['tag'] = args['--tag'] return data
def test_equalto_removed(self): args = {"--os": None, "--datacenter": "=ams01", "--memory": "=1g", "--test": "=1344"} argnew = helpers.sanitize_args(args) self.assertEqual(argnew, {"--os": None, "--datacenter": "ams01", "--memory": "1g", "--test": "1344"})