コード例 #1
0
def resource_context() -> ResourceCommandContext:
    connectivity = ConnectivityContext(
        server_address="localhost",
        quali_api_port="9000",
        cloudshell_version="2020.1",
        cloudshell_api_scheme="http",
        cloudshell_api_port="8029",
        admin_auth_token="token",
    )
    resource_context_details = ResourceContextDetails(
        address="NA",
        app_context=AppContext(app_request_json="", deployed_app_json=""),
        description="",
        family="Cloud Provider",
        fullname="OpenStack Cloud Provider",
        id="a95027f6-98bf-4177-8d40-d610f0179107",
        model="OpenStack",
        name="OpenStack Cloud Provider",
        networks_info=None,
        shell_standard="",
        shell_standard_version="",
        type="Resource",
        attributes={
            f"{SHELL_NAME}.OpenStack Project Name": "admin",
            f"{SHELL_NAME}.Execution Server Selector": "",
            f"{SHELL_NAME}.OpenStack Physical Interface Name": "",
            f"{SHELL_NAME}.User": "******",
            f"{SHELL_NAME}.OpenStack Domain Name": "default",
            f"{SHELL_NAME}.OpenStack Management Network ID":
            "9ce15bef-c7a1-4982-910c-0427555236a5",  # noqa: E501
            f"{SHELL_NAME}.Floating IP Subnet ID":
            "b79772e5-3f2f-4bff-b106-61e666bd65e7",  # noqa: E501
            f"{SHELL_NAME}.OpenStack Reserved Networks":
            "192.168.1.0/24;192.168.2.0/24",  # noqa: E501
            f"{SHELL_NAME}.Password": "******",
            f"{SHELL_NAME}.VLAN Type": "VXLAN",
            f"{SHELL_NAME}.Controller URL":
            "http://openstack.example/identity",
        },
    )
    reservation_context = ReservationContextDetails(
        **{
            "domain": "Global",
            "owner_email": None,
            "description": "",
            "environment_name": "CloudShell Sandbox Template3",
            "environment_path": "CloudShell Sandbox Template3",
            "owner_user": "******",
            "saved_sandbox_id": "",
            "saved_sandbox_name": "",
            "reservation_id": "8574cce6-adba-4e2c-86f7-a146475943c6",
            "running_user": "******",
        }, )
    return ResourceCommandContext(connectivity, resource_context_details,
                                  reservation_context, [])
コード例 #2
0
def reservation_context_details():
    return ReservationContextDetails(
        **{
            "domain": "Global",
            "owner_email": None,
            "description": "",
            "environment_name": "CloudShell Sandbox Template3",
            "environment_path": "CloudShell Sandbox Template3",
            "owner_user": "******",
            "saved_sandbox_id": "",
            "saved_sandbox_name": "",
            "reservation_id": "8574cce6-adba-4e2c-86f7-a146475943c6",
            "running_user": "******",
        }, )
コード例 #3
0
 def _init_reservation_model():
     reservation_context = ReservationContextDetails(
         environment_name="",
         environment_path="",
         domain="Global",
         description="",
         owner_user="",
         owner_email="",
         reservation_id="77bf1176-25d2-4dd0-ac58-05f8aee534a5",
         saved_sandbox_name="",
         saved_sandbox_id="",
         running_user="",
     )
     reservation_model = ReservationModel(reservation_context)
     return reservation_model
コード例 #4
0
def get_reservation_context_details():
    """
    Get the reservation details for this execution
    These details are automatically passed to the driver by CloudShell

    :rtype: ReservationContextDetails
    """
    res_dict = get_reservation_context_details_dict()
    res_details = ReservationContextDetails(environment_name=res_dict['environmentName'],
                                            environment_path=res_dict['environmentPath'],
                                            domain=res_dict['domain'],
                                            description=res_dict['description'],
                                            owner_user=res_dict['ownerUser'],
                                            owner_email='no-email',
                                            reservation_id=res_dict['id'],
                                            saved_sandbox_name=res_dict['savedSandboxId'],
                                            saved_sandbox_id='',
                                            running_user=res_dict['runningUser'])
    return res_details
コード例 #5
0
if __name__ == "__main__":
    import mock
    from cloudshell.shell.core.driver_context import ResourceCommandContext, ResourceContextDetails, ReservationContextDetails

    address = "192.168.26.24"
    user = "******"
    password = "******"
    port = 5240

    context = ResourceCommandContext(*(None, ) * 4)
    context.resource = ResourceContextDetails(*(None, ) * 13)
    context.resource.name = "MAAS"
    context.resource.fullname = "Canonical MAAS"
    context.resource.address = address
    context.resource.family = "CS_CloudProvider"
    context.reservation = ReservationContextDetails(*(None, ) * 7)
    context.reservation.reservation_id = '0cc17f8c-75ba-495f-aeb5-df5f0f9a0e97'
    context.resource.attributes = {}

    for attr, value in [
        ("User", user),
        ("Password", password),
        ("Scheme", "http"),
            # ("Managed Allocation", "True"),
        ("Port", port)
    ]:

        context.resource.attributes["{}.{}".format(MaasDriver.SHELL_NAME,
                                                   attr)] = value
        context.connectivity = mock.MagicMock()
        context.connectivity.server_address = "192.168.85.27"
コード例 #6
0
    def prepare_context(address="192.168.85.14", user="******", password="******", port=6666):
        """
        :return:
        """
        """Return initialized driver instance"""
        context = ResourceCommandContext(*(None,) * 4)
        context.resource = ResourceContextDetails(*(None,) * 13)
        context.resource.name = "CGS COS Loadbalancer Shell 2G"
        context.resource.fullname = "CGS COS Loadbalancer Shell 2G"
        context.resource.address = address
        context.resource.family = "CS_LoadBalancer"
        context.reservation = ReservationContextDetails(*(None,) * 7)
        context.reservation.reservation_id = '0cc17f8c-75ba-495f-aeb5-df5f0f9a0e97'
        context.resource.attributes = {}

        for attr, value in [("User", user),
                            ("Sessions Concurrency Limit", 1),
                            ("CLI Connection Type", "SSH"),
                            ("Password", password),
                            ("Enable Password", password),
                            ("CLI TCP Port", port),

                            # Backup location attributes for the "Save" command
                            ("Backup Location", ""),
                            ("Backup Type", "File System"),
                            ("Backup User", "backup_user"),
                            ("Backup Password", "backup_pass"),

                            # SNMP v2 Read-only
                            ("SNMP Version", "2"),
                            ("Enable SNMP", "True"),
                            ("Disable SNMP", "True"),
                            ("SNMP Read Community", "public_testing_2"),
                            # End SNMP v2 Read-only

                            # SNMP v2 Read-Write
                            # ("SNMP Version", "2"),
                            # ("Enable SNMP", "True"),
                            # ("Disable SNMP", "False"),
                            # ("SNMP Write Community", "public_33"),
                            # End SNMP v2 Read-Write

                            # SNMP v3
                            # ("SNMP Version", "3"),
                            # ("Enable SNMP", "True"),
                            # ("Disable SNMP", "True"),
                            # ("SNMP V3 User", "quali_NEW_NEW2"),
                            # ("SNMP V3 Password", "qualipass"),
                            # ("SNMP V3 Private Key", "qualipass2"),
                            # ("SNMP V3 Authentication Protocol", "No Authentication Protocol"),
                            # "No Authentication Protocol", "MD5", "SHA"
                            ("SNMP V3 Privacy Protocol", "No Privacy Protocol"),
                            # "No Privacy Protocol", "DES", "3DES-EDE", "AES-128", "AES-192", "AES-256"
                            # End SNMP v3
                            ]:

            context.resource.attributes["{}.{}".format(CgsCosLoadbalancerShell2GDriver.SHELL_NAME, attr)] = value
            context.connectivity = mock.MagicMock()
            context.connectivity.server_address = "192.168.85.10"

        return context
コード例 #7
0
                        domain='Global',
                        server_address=CS_SERVER,
                        reservation_id=LIVE_SANDBOX_ID,
                        resource_name=RESOURCE_NAME)

session = sh.get_api_session()
token = session.token_id

resource_context_details = sh.get_resource_context_details()
reservation_context_details = sh.get_reservation_context_details()
reservation_context = ReservationContextDetails(
    environment_name=reservation_context_details.environment_name,
    environment_path=reservation_context_details.environment_path,
    domain=reservation_context_details.domain,
    description=reservation_context_details.description,
    owner_user=reservation_context_details.owner_user,
    owner_email="*****@*****.**",
    reservation_id=reservation_context_details.id,
    saved_sandbox_name="",
    saved_sandbox_id="",
    running_user="")

connectivity_context_details = sh.get_connectivity_context_details()
cs_api_port = connectivity_context_details.cloudshell_api_port
connectivity_context = ConnectivityContext(server_address=CS_SERVER,
                                           cloudshell_api_port=cs_api_port,
                                           quali_api_port="9000",
                                           admin_auth_token=token,
                                           cloudshell_version="9.3",
                                           cloudshell_api_scheme="")
コード例 #8
0
    def prepare_context():
        """

        :return:
        """
        """Return initialized driver instance"""
        address = '192.168.105.30'
        user = '******'
        password = '******'
        port = 443
        auth_key = 'h8WRxvHoWkmH8rLQz+Z/pg=='
        api_port = 8029

        context = ResourceCommandContext(*(None,) * 4)
        context.resource = ResourceContextDetails(*(None,) * 13)
        context.resource.name = "Cumulus Linux Switch"
        context.resource.fullname = "Cumulus Linux Switch"
        context.resource.address = address
        context.resource.family = "CS_Switch"
        context.reservation = ReservationContextDetails(*(None,) * 7)
        context.reservation.reservation_id = '0cc17f8c-75ba-495f-aeb5-df5f0f9a0e97'
        context.resource.attributes = {}

        for attr, value in [("User", user),
                            ("Sessions Concurrency Limit", 1),

                            # Backup location attributes for the "Save" command
                            ("Backup Location", "/home/cumulus/backups"),
                            ("Backup Type", "File System"),
                            ("Backup User", "backup_user"),
                            ("Backup Password", "backup_pass"),

                            # Backup location attributes for the "Save" command
                            # ("Backup Location", "192.168.85.13/home/quali/"),
                            # ("Backup Type", "scp"),
                            # ("Backup User", "quali"),
                            # ("Backup Password", "quali"),


                            # SNMP v2 Read-only
                            # ("SNMP Version", "2"),
                            # ("Enable SNMP", "True"),
                            # ("Disable SNMP", "True"),
                            # ("SNMP Read Community", "mynotsosecretpassword"),
                            # End SNMP v2 Read-only

                            # SNMP v2 Read-Write
                            # ("SNMP Version", "2"),
                            # ("Enable SNMP", "True"),
                            # ("Disable SNMP", "False"),
                            # ("SNMP Write Community", "public"),
                            # End SNMP v2 Read-Write

                            # SNMP v3
                            ("SNMP Version", "3"),
                            ("Enable SNMP", "True"),
                            ("Disable SNMP", "True"),
                            ("SNMP V3 User", "quali"),
                            ("SNMP V3 Password", "qualipass"),
                            ("SNMP V3 Private Key", "qualipass2"),
                            ("SNMP V3 Authentication Protocol", "No Authentication Protocol"),
                            # "No Authentication Protocol", "MD5", "SHA"
                            ("SNMP V3 Privacy Protocol", "No Privacy Protocol"),
                            # "No Privacy Protocol", "DES", "3DES-EDE", "AES-128", "AES-192", "AES-256"
                            # End SNMP v3

                            ("Sessions Concurrency Limit", 1),
                            ("CLI Connection Type", "SSH"),
                            ("Password", password),
                            ("Enable Password", password)]:

            context.resource.attributes["{}.{}".format(CumulusLinuxSwitchShell2GDriver.SHELL_NAME, attr)] = value
            context.connectivity = mock.MagicMock()
            context.connectivity.server_address = "192.168.85.10"

        return context