def launch_vm(vmname, imagename, ip, key, flavorname, cloudinit=False, configdrive=False): nova = osclients.get_novaclient() glance = osclients.get_glanceclient() neutron = osclients.get_neutronclient() image_id=glance.images.find(name=imagename).id netid = neutron.list_networks(name='shared-net')['networks'][0]['id'] flavor = nova.flavors.find(name=flavorname) nic= {'net-id' : netid} extra_params = dict() if cloudinit: extra_params['userdata'] = cloud_init_meta if configdrive: extra_params['files'] = { '/etc/fiware-support/defaultssh.pub' : open('fake_test_key.pub'), '/etc/fiware-support/defaultgpg.pub': open('public-fake.gpg') } extra_params['config_drive'] = True extra_params['meta'] = { 'encrypt' : 'True' } server = nova.servers.create( vmname, flavor=flavor, image=image_id, key_name=key, security_groups=['default'], nics=[nic], **extra_params) time.sleep(2) #print server.adminPass if ip: server.add_floating_ip(ip) return server.id
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. # # For those usages not covered by the Apache version 2.0 License please # contact with [email protected] # from osclients import osclients import sys from subprocess import Popen, PIPE import novaclient.exceptions nova = osclients.get_novaclient() try: server = nova.servers.find(id=sys.argv[1]) except novaclient.exceptions.NotFound: server = nova.servers.find(name=sys.argv[1]) logs = server.get_console_output() encrypted = list() plain = None is_encrypted = False found = False gpg_block = False for line in logs.splitlines(): if gpg_block:
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. # # For those usages not covered by the Apache version 2.0 License please # contact with [email protected] # from osclients import osclients import sys from subprocess import Popen, PIPE import novaclient.exceptions nova = osclients.get_novaclient() try: server = nova.servers.find(id=sys.argv[1]) except novaclient.exceptions.NotFound: server = nova.servers.find(name=sys.argv[1]) logs = server.get_console_output() encrypted = list() plain = None is_encrypted = False found = False gpg_block = False for line in logs.splitlines(): if gpg_block: encrypted.append(line)