Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Compute] VM NIC updates #1421

Merged
merged 2 commits into from
Nov 24, 2016
Merged

[Compute] VM NIC updates #1421

merged 2 commits into from
Nov 24, 2016

Conversation

tjprescott
Copy link
Member

Fixes #783, fixes #785.

  • Adds vm nic show (which is basically an alias of az network nic show) and vm nic list
  • Combines --nic-ids and --nic-names into a single --nics parameter for existing commands Breaking Change
  • Incorporates vm nic commands into VM multi-NIC create scenario instead of relying on unit tests.
  • Renames vm nic delete to vm nic remove since it does NOT actually delete a NIC. Renames vm nic update to vm nic set since it does not update the settings but in fact replaces them. Breaking Change

@tjprescott tjprescott added Breaking Change Compute az vm/vmss/image/disk/snapshot Network az network vnet/lb/nic/dns/etc... New Command(s) labels Nov 23, 2016
@mention-bot
Copy link

@tjprescott, thanks for your PR! By analyzing the history of the files in this pull request, we identified @BurtBiel, @derekbekoe and @yugangw-msft to be potential reviewers.

Copy link
Contributor

@yugangw-msft yugangw-msft left a comment

Choose a reason for hiding this comment

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

The rest LGTM.

register_cli_argument('vm nic', 'vm_name', existing_vm_name, id_part=None)
register_cli_argument('vm nic', 'nic_ids', multi_ids_type)
register_cli_argument('vm nic', 'nic_names', multi_ids_type)
register_cli_argument('vm nic', 'vm_name', existing_vm_name, options_list=('--vm-name',), id_part=None)
Copy link
Contributor

Choose a reason for hiding this comment

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

is options_list=('--vm-name',) redundant?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, because existing_vm_name would make it --name, which isn't correct here.

cli_command(__name__, 'vm open-port', 'azure.cli.command_modules.vm.custom#vm_open_port')
op_var = 'virtual_machines_operations'
op_class = 'VirtualMachinesOperations'
cli_command(__name__, 'vm delete', mgmt_path.format(op_var, op_class, 'delete'), cf_vm)
Copy link
Contributor

Choose a reason for hiding this comment

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

//cc @derekbekoe. I am fine with this new style. As long as we agree, let us propagate this style across moving forward

Copy link
Member

Choose a reason for hiding this comment

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

Yep I'm fine with this!

def vm_show_nic(resource_group_name, vm_name, nic=None):
''' Show details of a network interface configuration attached to a virtual machine '''
vm = _vm_get(resource_group_name, vm_name)
found = next((n for n in vm.network_profile.network_interfaces if nic in n.id), None) # pylint: disable=no-member
Copy link
Contributor

Choose a reason for hiding this comment

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

nic in n.id should consider case insensitive matching. Also is nic always a id? If not, then in is not a reliable matching as it is possible the nic name will collide with any sub-str in the id.

Copy link
Member Author

@tjprescott tjprescott Nov 23, 2016

Choose a reason for hiding this comment

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

It is. The validator essentially takes names or ids and converts them to ids. I'll add the case insensitivity and change the matching to ==

Copy link
Member

@derekbekoe derekbekoe left a comment

Choose a reason for hiding this comment

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

one question.

@@ -693,20 +691,37 @@ def show_default_diagnostics_configuration(is_windows_os=False):
'''show the default config file which defines data to be collected'''
return get_default_diag_config(is_windows_os)

def vm_add_nics(resource_group_name, vm_name, nic_ids=None, nic_names=None, primary_nic=None):
'''add network interface configurations to the virtual machine
def vm_show_nic(resource_group_name, vm_name, nic=None):
Copy link
Member

Choose a reason for hiding this comment

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

Why is nic optional?
Lower down, you have if nic in n.id.

Copy link
Member Author

Choose a reason for hiding this comment

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

It should be required.

@yugangw-msft
Copy link
Contributor

:shipit:

@tjprescott tjprescott merged commit a8e234e into Azure:master Nov 24, 2016
@tjprescott tjprescott deleted the VmNicCommands branch November 24, 2016 00:30
thegalah pushed a commit to thegalah/azure-cli that referenced this pull request Nov 28, 2016
* Azure/master: (39 commits)
  User should use no-cache so we build a fresh image (Azure#1455)
  Bump all modules to version 0.1.0b10 (Azure#1454)
  [Docs] Move around the order of install instructions. (Azure#1439)
  acs: *_install_cli mark cli as executable (Azure#1449)
  Fix resource list table. (Azure#1452)
  [Compute] VM NIC updates (Azure#1421)
  Introduce batch upload and download for blob (Azure#1428)
  Add auto-registration for resource providers. (Azure#1330)
  interpret the '@' syntax if something higher hasn't already done that. (Azure#1423)
  Aliasing plan argument with shorthand (Azure#1433)
  ad:fix one more place which still uses localtime for secret starttime (Azure#1429)
  Add table formatting for deployments and sort by timestmap. (Azure#1427)
  Add table formatting for resource group list (and add 'status') (Azure#1425)
  [Docs] Add shields specifying latest version and supported python versions (Azure#1420)
  Add new az storage blob copy start-batch command (Azure#1250)
  Component Discovery (Azure#1409)
  Add poison logic to prevent re-recording tests that need updating. (Azure#1412)
  [Storage] Fix storage table outputs and help text. (Azure#1402)
  [mention-bot] Attempt to fix config (Azure#1410)
  ad:use utc time on setting app's creds (Azure#1408)
  ...
xscript pushed a commit to xscript/azure-cli that referenced this pull request Nov 30, 2016
**BC** Replace --nic-ids and --nic-names with --nics parameter for existing `vm nic` commands.
**BC** Renames `vm nic delete` to `vm nic remove` and `vm nic update` to `vm nic set`

* Add NIC show and list commands to VM NIC.

* Code review feedback.
@haroldrandom haroldrandom added Breaking Change cla-not-required Compute az vm/vmss/image/disk/snapshot Network az network vnet/lb/nic/dns/etc... New Command (PR) labels Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking Change cla-not-required Compute az vm/vmss/image/disk/snapshot Network az network vnet/lb/nic/dns/etc... New Command (PR)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants