{"action":"created","issue":{"url":"https://api.github.com/repos/saltstack/salt/issues/26733","labels_url":"https://api.github.com/repos/saltstack/salt/issues/26733/labels{/name}","comments_url":"https://api.github.com/repos/saltstack/salt/issues/26733/comments","events_url":"https://api.github.com/repos/saltstack/salt/issues/26733/events","html_url":"https://github.com/saltstack/salt/pull/26733","id":103730396,"number":26733,"title":"Refactor of smartos_vmadm module","user":{"login":"sjorge","id":379665,"avatar_url":"https://avatars.githubusercontent.com/u/379665?v=3","gravatar_id":"","url":"https://api.github.com/users/sjorge","html_url":"https://github.com/sjorge","followers_url":"https://api.github.com/users/sjorge/followers","following_url":"https://api.github.com/users/sjorge/following{/other_user}","gists_url":"https://api.github.com/users/sjorge/gists{/gist_id}","starred_url":"https://api.github.com/users/sjorge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjorge/subscriptions","organizations_url":"https://api.github.com/users/sjorge/orgs","repos_url":"https://api.github.com/users/sjorge/repos","events_url":"https://api.github.com/users/sjorge/events{/privacy}","received_events_url":"https://api.github.com/users/sjorge/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/saltstack/salt/labels/Execution%20Module","name":"Execution Module","color":"006b75"},{"url":"https://api.github.com/repos/saltstack/salt/labels/Master%20Change","name":"Master Change","color":"0052cc"},{"url":"https://api.github.com/repos/saltstack/salt/labels/Platform","name":"Platform","color":"fef2c0"},{"url":"https://api.github.com/repos/saltstack/salt/labels/Tests%20Passed","name":"Tests Passed","color":"009800"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-08-28T14:38:41Z","updated_at":"2015-08-28T22:40:38Z","closed_at":"2015-08-28T16:42:23Z","pull_request":{"url":"https://api.github.com/repos/saltstack/salt/pulls/26733","html_url":"https://github.com/saltstack/salt/pull/26733","diff_url":"https://github.com/saltstack/salt/pull/26733.diff","patch_url":"https://github.com/saltstack/salt/pull/26733.patch"},"body":"This is part 1 of 2 (or 3) of the vmadm execution module refactor mentioned in #26507 \r\n  * moved smartos_vmadm.py to smartos_legacy.py\r\n  * added deprecation warning to smartos_legacy.py (__virtual__ = 'virt')\r\n  * create new smartos_vmadm.py (__virtual__ = 'vmadm') that closely mirrors the vmadm command on SmartOS\r\n\r\n## vmadm.create\r\n```\r\n[root@core ~]# /opt/local/salt/bin/salt-call --local vmadm.create brand=joyent image_uuid=c02a2044-c1bd-11e4-bd8c-dfc1db8b0182 hostname=test.example.org alias=test autoboot=false nowait=false cpu_shares=50 cpu_cap=125 max_physical_memory=256 quota=1 zfs_io_priority=50 zfs_root_compression=lz4 nics='[{ \"nic_tag\": \"trunk\", \"mtu\": 1500, \"vlan_id\": 10, \"ip\": \"172.16.xx.121\", \"netmask\": \"255.255.255.0\" }]'\r\n[INFO    ] Executing command 'echo \\'{\"nowait\": false, \"zfs_root_compression\": \"lz4\", \"alias\": \"test\", \"nics\": [{\"ip\": \"172.16.xx.121\", \"netmask\": \"255.255.255.0\", \"nic_tag\": \"trunk\", \"vlan_id\": 10, \"mtu\": 1500}], \"brand\": \"joyent\", \"hostname\": \"test.example.org\", \"quota\": 1, \"max_physical_memory\": 256, \"autoboot\": false, \"cpu_cap\": 125, \"image_uuid\": \"c02a2044-c1bd-11e4-bd8c-dfc1db8b0182\", \"zfs_io_priority\": 50, \"cpu_shares\": 50}\\' | /usr/sbin/vmadm validate create ' in directory '/root'\r\n[INFO    ] Executing command 'echo \\'{\"nowait\": false, \"zfs_root_compression\": \"lz4\", \"alias\": \"test\", \"nics\": [{\"ip\": \"172.16.xx.121\", \"netmask\": \"255.255.255.0\", \"nic_tag\": \"trunk\", \"vlan_id\": 10, \"mtu\": 1500}], \"brand\": \"joyent\", \"hostname\": \"test.example.org\", \"quota\": 1, \"max_physical_memory\": 256, \"autoboot\": false, \"cpu_cap\": 125, \"image_uuid\": \"c02a2044-c1bd-11e4-bd8c-dfc1db8b0182\", \"zfs_io_priority\": 50, \"cpu_shares\": 50}\\' | /usr/sbin/vmadm create ' in directory '/root'\r\nlocal:\r\n    4ed3416e-73bf-4f87-b49c-3b33eb6b520d\r\n```\r\n## vmadm.update\r\n```\r\n[root@core ~]# /opt/local/salt/bin/salt-call --local vmadm.update vm=4ed3416e-73bf-4f87-b49c-3b33eb6b520d max_physical_memory=1024\r\n[INFO    ] Executing command '/usr/sbin/vmadm lookup -1  uuid=4ed3416e-73bf-4f87-b49c-3b33eb6b520d' in directory '/root'\r\n[INFO    ] Executing command '/usr/sbin/vmadm lookup -1  uuid=4ed3416e-73bf-4f87-b49c-3b33eb6b520d' in directory '/root'\r\n[INFO    ] Executing command '/usr/sbin/vmadm get 4ed3416e-73bf-4f87-b49c-3b33eb6b520d' in directory '/root'\r\n[INFO    ] Executing command 'echo \\'{\"max_physical_memory\": 1024}\\' | /usr/sbin/vmadm validate update joyent' in directory '/root'\r\n[INFO    ] Executing command 'echo \\'{\"max_physical_memory\": 1024}\\' | /usr/sbin/vmadm update 4ed3416e-73bf-4f87-b49c-3b33eb6b520d' in directory '/root'\r\nlocal:\r\n    True\r\n```\r\n## vmadm.get\r\n```\r\n[root@core ~]# /opt/local/salt/bin/salt-call --local vmadm.get 4ed3416e-73bf-4f87-b49c-3b33eb6b520d\r\n[INFO    ] Executing command '/usr/sbin/vmadm lookup -1  uuid=4ed3416e-73bf-4f87-b49c-3b33eb6b520d' in directory '/root'\r\n[INFO    ] Executing command '/usr/sbin/vmadm get 4ed3416e-73bf-4f87-b49c-3b33eb6b520d' in directory '/root'\r\nlocal:\r\n    ----------\r\n    alias:\r\n        test\r\n    autoboot:\r\n        False\r\n    billing_id:\r\n        00000000-0000-0000-0000-000000000000\r\n    brand:\r\n        joyent\r\n    cpu_cap:\r\n        125\r\n    cpu_shares:\r\n        50\r\n    create_timestamp:\r\n        2015-08-28T14:34:27.951Z\r\n    customer_metadata:\r\n        ----------\r\n    dns_domain:\r\n        local\r\n    firewall_enabled:\r\n        False\r\n    hostname:\r\n        test.example.org\r\n    image_uuid:\r\n        c02a2044-c1bd-11e4-bd8c-dfc1db8b0182\r\n    internal_metadata:\r\n        ----------\r\n    last_modified:\r\n        2015-08-28T14:36:30.000Z\r\n    limit_priv:\r\n        default\r\n    max_locked_memory:\r\n        1024\r\n    max_lwps:\r\n        2000\r\n    max_msg_ids:\r\n        4096\r\n    max_physical_memory:\r\n        1024\r\n    max_sem_ids:\r\n        4096\r\n    max_shm_ids:\r\n        4096\r\n    max_shm_memory:\r\n        256\r\n    max_swap:\r\n        1024\r\n    nics:\r\n        |_\r\n          ----------\r\n          interface:\r\n              net0\r\n          ip:\r\n              172.16.xx.121\r\n          mac:\r\n              42:6c:da:cb:97:af\r\n          mtu:\r\n              1500\r\n          netmask:\r\n              255.255.255.0\r\n          nic_tag:\r\n              trunk\r\n          primary:\r\n              True\r\n          vlan_id:\r\n              10\r\n    owner_uuid:\r\n        00000000-0000-0000-0000-000000000000\r\n    platform_buildstamp:\r\n        20150820T062742Z\r\n    quota:\r\n        1\r\n    resolvers:\r\n    routes:\r\n        ----------\r\n    server_uuid:\r\n        00000000-0000-0000-0000-002590f15506\r\n    snapshots:\r\n    state:\r\n        stopped\r\n    tags:\r\n        ----------\r\n    tmpfs:\r\n        1024\r\n    uuid:\r\n        4ed3416e-73bf-4f87-b49c-3b33eb6b520d\r\n    v:\r\n        1\r\n    zfs_filesystem:\r\n        zones/4ed3416e-73bf-4f87-b49c-3b33eb6b520d\r\n    zfs_io_priority:\r\n        50\r\n    zfs_root_compression:\r\n        lz4\r\n    zfs_root_recsize:\r\n        131072\r\n    zone_state:\r\n        installed\r\n    zoneid:\r\n        None\r\n    zonename:\r\n        4ed3416e-73bf-4f87-b49c-3b33eb6b520d\r\n    zonepath:\r\n        /zones/4ed3416e-73bf-4f87-b49c-3b33eb6b520d\r\n    zpool:\r\n        zones\r\n```\r\n\r\n## vmadm.lookup\r\n```\r\n[root@core ~]# /opt/local/salt/bin/salt-call --local vmadm.lookup search='alias=opnsense' one=True\r\n[INFO    ] Executing command '/usr/sbin/vmadm lookup -1  alias=opnsense' in directory '/root'\r\nlocal:\r\n    186da9ab-7392-4f55-91a5-b8f1fe770543\r\n```\r\n\r\n## vmadm.start\r\n```\r\n[root@core ~]# /opt/local/salt/bin/salt-call --local vmadm.start 4ed3416e-73bf-4f87-b49c-3b33eb6b520d\r\n[INFO    ] Executing command '/usr/sbin/vmadm lookup -1  uuid=4ed3416e-73bf-4f87-b49c-3b33eb6b520d' in directory '/root'\r\n[INFO    ] Executing command '/usr/sbin/vmadm start 4ed3416e-73bf-4f87-b49c-3b33eb6b520d ' in directory '/root'\r\nlocal:\r\n    True\r\n```\r\n\r\n## vmadm.stop\r\n```\r\n[root@core ~]# /opt/local/salt/bin/salt-call --local vmadm.stop 4ed3416e-73bf-4f87-b49c-3b33eb6b520d force=True\r\n[INFO    ] Executing command '/usr/sbin/vmadm lookup -1  uuid=4ed3416e-73bf-4f87-b49c-3b33eb6b520d' in directory '/root'\r\n[INFO    ] Executing command '/usr/sbin/vmadm stop -F 4ed3416e-73bf-4f87-b49c-3b33eb6b520d' in directory '/root'\r\nlocal:\r\n    True\r\n```\r\n\r\n## vmadm.info\r\n```\r\n[root@core ~]# /opt/local/salt/bin/salt-call --local vmadm.info opnsense vnc key=alias\r\n[INFO    ] Executing command '/usr/sbin/vmadm lookup -1  alias=opnsense' in directory '/root'\r\n[INFO    ] Executing command '/usr/sbin/vmadm info 186da9ab-7392-4f55-91a5-b8f1fe770543 vnc' in directory '/root'\r\nlocal:\r\n    ----------\r\n    vnc:\r\n        ----------\r\n        display:\r\n            1\r\n        host:\r\n            172.16.xx.120\r\n        port:\r\n            5901\r\n```\r\n\r\n## vmadm.list\r\n```\r\n[root@core ~]# /opt/local/salt/bin/salt-call --local vmadm.list\r\n[INFO    ] Executing command '/usr/sbin/vmadm list -p -H -o uuid,type,ram,state,alias  ' in directory '/root'\r\nlocal:\r\n    |_\r\n      ----------\r\n      alias:\r\n          nina\r\n      ram:\r\n          2048\r\n      state:\r\n          stopped\r\n      type:\r\n          KVM\r\n      uuid:\r\n          618a01b8-c37b-473f-8cdb-ca2a66d6adf7\r\n    |_\r\n      ----------\r\n      alias:\r\n          jiska\r\n      ram:\r\n          4096\r\n      state:\r\n          running\r\n      type:\r\n          OS\r\n      uuid:\r\n          260014e8-33db-42c0-8ce4-2a7929a5ef08\r\n    |_\r\n      ----------\r\n      alias:\r\n          silke\r\n      ram:\r\n          8192\r\n      state:\r\n          running\r\n      type:\r\n          LX\r\n      uuid:\r\n          306b5291-3dc6-4947-8faa-6ec8da48ca6d\r\n```\r\n... there are a few more commands but this should give the jist of it. Most command vmadm has are present with the exaction of vmadm console which cannot be implemented without and interactive TTY.\r\n\r\nI will be on holiday next week, after that I will write a simplified wrapper to replace smartos_legacy.py and hopefully a state module when I figure out how they work."},"comment":{"url":"https://api.github.com/repos/saltstack/salt/issues/comments/135904440","html_url":"https://github.com/saltstack/salt/pull/26733#issuecomment-135904440","issue_url":"https://api.github.com/repos/saltstack/salt/issues/26733","id":135904440,"user":{"login":"basepi","id":702318,"avatar_url":"https://avatars.githubusercontent.com/u/702318?v=3","gravatar_id":"","url":"https://api.github.com/users/basepi","html_url":"https://github.com/basepi","followers_url":"https://api.github.com/users/basepi/followers","following_url":"https://api.github.com/users/basepi/following{/other_user}","gists_url":"https://api.github.com/users/basepi/gists{/gist_id}","starred_url":"https://api.github.com/users/basepi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/basepi/subscriptions","organizations_url":"https://api.github.com/users/basepi/orgs","repos_url":"https://api.github.com/users/basepi/repos","events_url":"https://api.github.com/users/basepi/events{/privacy}","received_events_url":"https://api.github.com/users/basepi/received_events","type":"User","site_admin":false},"created_at":"2015-08-28T22:40:37Z","updated_at":"2015-08-28T22:40:37Z","body":"Hey @sjorge, this is conflicting in huge ways with the work that @isbm has done on the develop branch. 17 conflicting sections. Because I do not know the code, I am not equipped to handle this merge conflict. So, for the moment, I am going to take the develop branch's version.\r\n\r\nI know it's far from convenient, but could you make your additions separately on that branch? That's the best way I can see for combining yours and @isbm's changes, is if you make yours on top of his.\r\n\r\nSorry again for the inconvenience."}}