コード例 #1
0
    def _run(self, args_str=None, oper=''):
        self._args = None
        if not args_str:
            args_str = ' '.join(sys.argv[1:])
        self._parse_args(args_str)

        if self._quantum == None:
            httpclient = HTTPClient(
                username='******',
                tenant_name='demo',
                password='******',
                # region_name=self._region_name,
                auth_url='http://%s:5000/v2.0' % (self._args.api_server_ip))
            httpclient.authenticate()

            #OS_URL = httpclient.endpoint_url
            OS_URL = 'http://%s:9696/' % (self._args.api_server_ip)
            OS_TOKEN = httpclient.auth_token
            self._quantum = client.Client('2.0',
                                          endpoint_url=OS_URL,
                                          token=OS_TOKEN)

            self._vnc_lib = VncApi(username=self._args.admin_user,
                                   password=self._args.admin_password,
                                   tenant_name=self._args.admin_tenant_name,
                                   api_server_host=self._args.api_server_ip,
                                   api_server_port=self._args.api_server_port,
                                   api_server_url='/',
                                   auth_host=self._args.api_server_ip)

            self._proj_obj = self._vnc_lib.project_read(
                fq_name=['default-domain', 'default-project'])
            self._ipam_obj = self._vnc_lib.network_ipam_read(fq_name=[
                'default-domain', 'default-project', 'default-network-ipam'
            ])

        if self._args.oper == 'add':
            self._create_vn(self._args.vn_name, self._args.public_subnet)
        elif self._args.oper == 'del':
            self._delete_vn(self._args.vn_name)
        elif self._args.oper == 'add-list':
            self._create_vn_list(self._args.vn_list)
コード例 #2
0
 def setUp(self):
     self.obj = client.Client(
         '2.0',
         session=self.auth_h.get_session(scope='project'),
         region_name=self.region_name)