def all_in_one(): t = tenant_create() u = user_create(t) d = { "username": u.username, "password": "******", "tenant_name": t.name, "auth_url": "http://14.14.14.100:5000/v2.0" } print d network = network_create(d) ins = Instance.objects.get(pk=2) f = flavor_create(d, ins) print f nova.server_create(d, name="instance-%08d" % ins.id, image="1b21bcec-d8b3-4ad9-8f17-3b98f7d6adf6", flavor=f.id, key_name=None, user_data=None, security_groups=[], nics=[{ "net-id": network.id, "v4-fixed-ip": "" }], availability_zone="nova", admin_pass="******")
def instance_create(instance, password): user_data_format = "#cloud-config\npassword: %s\nchpasswd: { expire: False }\nssh_pwauth: True\n" user_data = user_data_format % password rc = create_rc_by_instance(instance) try: if instance.image.os_type == LINUX: server = nova.server_create(rc, name=instance.name, image=instance.image.uuid, flavor=instance.flavor_id, key_name=None, security_groups=[], nics = [{"net-id": instance.network.network_id, "v4-fixed-ip": ""}], user_data = user_data ) elif instance.image.os_type == WINDOWS: server = nova.server_create(rc, name=instance.name, image=instance.image.uuid, flavor=instance.flavor_id, key_name=None, user_data=None, security_groups=[], nics = [{"net-id": instance.network.network_id, "v4-fixed-ip": ""}], meta = {"admin_pass": password}, ) else: raise Exception("unknown image os type.") return server except Exception as e: LOG.exception(e) return False
def instance_create(request, instance): nova.server_create(request, name="instance-%08d" % instance.id, image=instance.image, flavor=instance.flavor_id, key_name=None, user_data=None, security_groups=[], nics=nics, availability_zone="Nova", admin_pass=instance.admin_pass)
def instance_create(instance, password): if instance.image.os_type not in (LINUX, WINDOWS): raise ValueError(u"Unknown image os type, [%s].", instance) user_data_format = "#cloud-config\n"\ "password: %s\n"\ "chpasswd: { expire: False }\n"\ "ssh_pwauth: True\n" user_data = user_data_format % password rc = create_rc_by_instance(instance) # nic is alias of Network interface card nics = None if neutron.is_neutron_enabled(rc): nics = [{"net-id": instance.network.network_id, "v4-fixed-ip": ""}] if instance.image.os_type == LINUX: server = nova.server_create(rc, name=instance.name, image=instance.image.uuid, flavor=instance.flavor_id, key_name=None, security_groups=[], nics=nics, user_data=user_data) else: new_pwd = [] for c in password: if c in ["&", "|", "(", ")", "<", ">", "^"]: new_pwd.append("^") new_pwd.append(c) password = "".join(new_pwd) LOG.info(u"Windows complexity password, [%s][%s].", instance, password) server = nova.server_create(rc, name=instance.name, image=instance.image.uuid, flavor=instance.flavor_id, key_name=None, user_data=None, security_groups=[], nics=nics, meta={"admin_pass": password}) return server
def instance_create(instance, password): user_data_format = "#cloud-config\npassword: %s\nchpasswd: { expire: False }\nssh_pwauth: True\n" user_data = user_data_format % password rc = create_rc_by_instance(instance) try: nics = None if neutron.is_neutron_enabled(rc): nics = [{"net-id": instance.network.network_id, "v4-fixed-ip": ""}] if instance.image.os_type == LINUX: server = nova.server_create(rc, name=instance.name, image=instance.image.uuid, flavor=instance.flavor_id, key_name=None, security_groups=[], nics = nics, user_data = user_data, ) elif instance.image.os_type == WINDOWS: server = nova.server_create(rc, name=instance.name, image=instance.image.uuid, flavor=instance.flavor_id, key_name=None, user_data=None, security_groups=[], nics = nics, meta = {"admin_pass": password}, ) else: raise Exception("unknown image os type.") return server except Exception as e: instance.status = INSTANCE_STATE_ERROR instance.save() LOG.exception(e) return False
def all_in_one(): t = tenant_create() u = user_create(t) d = {"username": u.username, "password": "******", "tenant_name": t.name, "auth_url": "http://14.14.14.100:5000/v2.0"} print d network = network_create(d) ins = Instance.objects.get(pk=2) f = flavor_create(d, ins) print f nova.server_create(d, name="instance-%08d" % ins.id, image="1b21bcec-d8b3-4ad9-8f17-3b98f7d6adf6", flavor=f.id, key_name=None, user_data=None, security_groups=[], nics = [{"net-id": network.id, "v4-fixed-ip": ""}], availability_zone="nova", admin_pass="******" )