Skip to content

Conversation

khuong507
Copy link

No description provided.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 85.989% when pulling a133971 on khuong507:dedicateCommand into dc97e7e on softlayer:master.

Copy link
Member

@allmightyspiff allmightyspiff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good. My biggest concern is some of the hard coding around the dedicated host size stuff.

help="Host portion of the FQDN",
required=True,
prompt=True)
@click.option('--router', '-r',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. unless its wildly complicated, I would prefer to pass in the router hostname, fcr02a.dal13 or something
  2. Is specifying a VLAN not an option for dedicated hosts?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Specifying a VLAN is not an option for dedicated hosts

default='hourly',
show_default=True,
help="Billing rate")
@click.option('--test',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer --verify, or --dry-run instead of test.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently virtual servers and hardware use --test. Would you still like it changed?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah --test isn't too descriptive. I'd personally prefer --verify. Might want to make the help a little more descriptive to say it only verifies the dedicated host order without placing it.

'hourly': args.get('billing') == 'hourly',
}

do_create = not (args['test'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are already testing this on line 55, just change line 84 to else:

if args.get('test'):
result = mgr.verify_order(**order)

table = formatting.Table(['Item', 'cost'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to include this pricing information in the order output as well.

"""host order options for a given dedicated host."""

mgr = SoftLayer.DedicatedHostManager(env.client)
options = mgr.get_create_options()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If its not too hard I'd also like to output the available routers (and vlans if possible) per DC here.


def _get_item(self, package):
"""Returns the item for ordering a dedicated host."""
description = '56 Cores X 242 RAM X 1.2 TB'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see this being problematic if we ever have more dedicated host sizes. I'd also prefer we check keynames not descriptions.
_get_item(self, package, itemKey='DEDICATED_HSOT')

or something like that.

for location in locations:
if location['locationId'] is not None:
loc_id = location['locationId']
host = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see this being problematic if more dedicated host sizes are added. This should be calculated from the package or supplied by the CLI I think.

Unless its possible to not supply this data at all and just get a list of routers without specifying a template

@allmightyspiff allmightyspiff self-assigned this Nov 22, 2017
@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 86.03% when pulling 913e721 on khuong507:dedicateCommand into dc97e7e on softlayer:master.

Copy link

@rlrossiter rlrossiter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've taken a first pass at this, mostly focusing on the create CLI and the manager. I'll take a deeper look at this later.

type=click.Path(writable=True, resolve_path=True),
help="Exports options to a template file")
@environment.pass_env
def cli(env, **args):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know virt/create:cli does **args, but I find that really confusing since they're more conventionally **kwargs.

Though in my opinion, even though you do have a lot of options, I think it would be easier to read and see what options are all possibly going to be coming in on the cli by explicitly outlining all of the command line args that are coming in here.

'hostname': args['hostname'],
'domain': args['domain'],
'flavor': args['flavor'],
'router': args['router'],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since router is optional, this may not be defined in the args. I think the @click.option decorator will make it a kwarg for you, so you don't need to worry about a key error here, but it will be set to None if it isn't set on the command line. Is that what this is supposed to be set to if no router is specified?

If not, I'd put the things you know will be set in the order (i.e. the mandatory items) in this initial dict creation, and then add things in later if needed, like:

if args['router']:
    order['router'] = args['router']

'domain': args['domain'],
'flavor': args['flavor'],
'router': args['router'],
'location': args.get('datacenter'),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be set doesn't it? It's required by the CLI, so it should just be args['datacenter']

.get() will return None if it isn't set, which you probably don't want to pass in the order

default='hourly',
show_default=True,
help="Billing rate")
@click.option('--test',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah --test isn't too descriptive. I'd personally prefer --verify. Might want to make the help a little more descriptive to say it only verifies the dedicated host order without placing it.

if len(result['prices']) != 1:
raise exceptions.ArgumentError("More than 1 price was found or no "
"prices found")
price = result['prices']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set price = result['prices'][0] here, because price[0] looks weird down below (and you're doing it twice so that helps clean up the below a little more)

return

if do_create:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you wanted to be changing this file

'sort': 0
}]

verifyOrderDH = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what the normal process is around adding fixtures, but this seems a little long. Do we want this reduced down so it only has the fields that you need? This question is more for @allmightyspiff

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really have a strong opinion on this at the moment.


kwargs['filter'] = _filter.to_dict()
func = getattr(self.account, call)
return func(**kwargs)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of making this roundabout way of calling getDedicatedHosts, I'd just use self.account.getDedicatedHosts(**kwargs)


raise SoftLayer.SoftLayerError("Could not find available routers")

def _get_default_router(self, routers, router_name):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for readability, since router_name isn't required, default it to None in the args here. Even though you always supply it above (and it's None because it's optional in _generate_create_dict()), I'd still be explicit with router_name=None

Copy link

@rlrossiter rlrossiter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few more comments added from going through it a little closer.

" ex. 56_CORES_X_242_RAM_X_1_4_TB",
show_default=True)
@environment.pass_env
def cli(env, **args):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for **kwargs here as in create. Though I would really just lean towards having datacenter and flavor as explicit kwargs for the function

else:
if args['flavor'] is None or args['datacenter'] is None:
raise exceptions.ArgumentError('Both a flavor and datacenter need '
'to be passed as arguments\n'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't do a '\n' in an exception string, just let it all flow on one line. If you want a separator for the example, maybe just put the example in parentheses

table.add_row(['router hostname', result['backendRouter']['hostname']])
if utils.lookup(result, 'billingItem') != {}:
table.add_row(['owner', formatting.FormattedItem(
utils.lookup(result, 'billingItem', 'orderItem',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't this lookup just return {} if billingItem wasn't set, so the if above isn't needed? Because either way if something in that lookup isn't set, you'll end up with formatting.blank() anyways

'createDate,'
'modifyDate,'
'backendRouter[id, hostname, domain],'
'billingItem[id, nextInvoiceTotalRecurringAmount, '

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd think about reorganizing this to make it a little more readable, because it's not obvious the nesting structure of this mask (i.e. children and orderItem are under billingItem, but the brackets are hard to follow)

Maybe look at how masking is done where a docstring is used, where different indentation can be used to make nesting easier to read. The only problem with the docstring method is printing it out in the debugger can get a little difficult to read.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 86.03% when pulling a09d814 on khuong507:dedicateCommand into 7858dbd on softlayer:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.6%) to 86.214% when pulling 2abc785 on khuong507:dedicateCommand into 7858dbd on softlayer:master.

@khuong507
Copy link
Author

khuong507 commented Dec 12, 2017

I made the requested changes.

Copy link
Member

@allmightyspiff allmightyspiff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok looks good. I'll do some personal testing with this tomorrow and if everything works as expected I'll be ready to merge into master, and released some point next week.

'sort': 0
}]

verifyOrderDH = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really have a strong opinion on this at the moment.

@allmightyspiff
Copy link
Member

$ ./slcli  dedicatedhost create -H dedicatedHostTest -D cgallo.com -d  mex01 -f 56_CORES_X_242_RAM_X_1_4_TB --verify
Total hourly cost  0.00
 -- ! Prices reflected here are retail and do not take account level discounts and are not guaranteed.


./slcli  dedicatedhost create -H dedicatedHostTest -D cgallo.com -d  mex01 -f 56_CORES_X_242_RAM_X_1_4_TB
This action will incur charges on your account. Continue? [y/N]: y
Total hourly cost  0.00
 -- ! Prices reflected here are retail and do not take account level discounts and are not guaranteed.
id       21462711
created  2017-12-15T10:54:15-06:00


 ./slcli  dedicatedhost list
50701  ajcb-test          56  1200  242  mex01  1
10201  dedicated2         56  1200  242  dal10  NULL
64801  dedicatedHostTest  56  1200  242  mex01  NULL
10405  fmirDH             56  1200  242  dal09  1

@allmightyspiff allmightyspiff merged commit ea3edff into softlayer:master Dec 15, 2017
@khuong507 khuong507 deleted the dedicateCommand branch October 31, 2018 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants