def lanche_instance():
    compartment_id = getConfig("INSTANCE", "compartment_id")
    availability_domain = getConfig("INSTANCE", "availability_domain")
    shape = getConfig("INSTANCE", "shape")
    request = LaunchInstanceDetails()
    request.compartment_id = compartment_id
    request.availability_domain = availability_domain
    request.shape = shape
    instance = compute_client.launch_instance(request)
    return instance
def create_vcn():
    cidr_block = getConfig("VCN", "cidr_block")
    vcn_client = oci.core.VirtualNetworkClient(config)
    vcn_details = CreateVcnDetails()
    vcn_details.cidr_block = cidr_block
    vcn_details.display_name = "".join(
        random.sample(string.ascii_letters + string.digits, 8))
    vcn_details.compartment_id = getConfig("VCN", "compartment_id")
    vcn_result = vcn_client.create_vcn(vcn_details)
    get_vcn_response = oci.wait_until(vcn_client,
                                      vcn_client.get_vcn(vcn_result.data.id),
                                      'lifecycle_state', 'AVAILABLE')
    print('Created VCN:{}'.format(get_vcn_response.data.id))
    return get_vcn_response
def create_subnet(vcn):
    subnet_client = oci.core.VirtualNetworkClient(config)
    subnet_details = CreateSubnetDetails()
    subnet_details.cidr_block = getConfig("SUBNET", "cidr_block")
    subnet_details.display_name = "".join(
        random.sample(string.ascii_letters + string.digits, 8))
    subnet_details.compartment_id = getConfig("SUBNET", "compartment_id")
    subnet_details.availability_domain = getConfig("SUBNET",
                                                   "availability_domain")
    subnet_details.vcn_id = vcn.id
    subnet_result = subnet_client.create_subnet(subnet_details)
    get_subnet_response = oci.wait_until(
        subnet_client, subnet_client.get_subnet(subnet_result.data.id),
        'lifecycle_state', 'AVAILABLE')
    print('Created Subnet:{}'.format(get_subnet_response.data.id))
    return get_subnet_response
Example #4
0
import oci, os
from oci.identity.models import CreateUserDetails
from config_parse import getConfig

#os.environ['http_proxy'] = 'http://www-proxy-hqdc.us.oracle.com:80'
#os.environ['https_proxy'] = 'http://www-proxy-hqdc.us.oracle.com:80'


#config=oci.config.from_file()
#identity=oci.identity.IdentityClient(config)

signer = oci.auth.signers.InstancePrincipalsSecurityTokenSigner()
identity = oci.identity.IdentityClient(config={}, signer=signer)

#compartment_id=config["tenancy"]
compartment_id=getConfig("User","compartment_id")

user_id=getConfig("User","user_id")
user=identity.get_user(user_id)


userList=identity.list_users(compartment_id)
print(user.data)
Example #5
0
import oci, os
from oci.identity.models import CreateUserDetails
from config_parse import getConfig

os.environ['http_proxy'] = 'http://www-proxy-hqdc.us.oracle.com:80'
os.environ['https_proxy'] = 'http://www-proxy-hqdc.us.oracle.com:80'

config = oci.config.from_file()
identity = oci.identity.IdentityClient(config)

compartment_id = config["tenancy"]

user_id = getConfig("User", "user_id")
user = identity.get_user(user_id)

userList = identity.list_users(compartment_id)
print(userList.data)
def get_instance():
    instance_id = getConfig("INSTANCE", "instance_id")
    instance = compute_client.get_instance(instance_id)
    return instance
def list_instances():
    compartment_id = getConfig("INSTANCE", "compartment_id")
    instance_list = compute_client.list_instances(compartment_id)
    return instance_list
Example #8
0
def list_user():
    compartment_id_ = getConfig("User", "compartment_id")
    user_list = identity.list_users(compartment_id_)
    return user_list
Example #9
0
def get_user():
    user_id = getConfig("User", "user_id")
    user = identity.get_user(user_id)
    return user